Skip to content

Instantly share code, notes, and snippets.

@line-o
Last active February 11, 2023 19:58
Show Gist options
  • Save line-o/4896d177c5d9b429d08c81b24c3fda3c to your computer and use it in GitHub Desktop.
Save line-o/4896d177c5d9b429d08c81b24c3fda3c to your computer and use it in GitHub Desktop.
Illustrate a bug in existdb that leads to exist.log polluted with error messages
<html>
<body>
<script type="text/javascript"><![CDATA[ console.log(true && 1 < 2) ]]></script>
</body>
</html>
export EXISTDB_USER="admin"
export EXISTDB_PASS=""
# get this gist
git clone https://gist.github.com/line-o/4896d177c5d9b429d08c81b24c3fda3c test
# upload testfiles to local development instance
xst up test /db/apps/test
xst run "sm:chmod(xs:anyURI('/db/apps/test/traverse.xq'), 'o+x')"
# execute the test code
curl http://localhost:8080/exist/apps/test/traverse.xq
# inform what to do next
echo "now check exist.log for error messages"
xquery version "3.1";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "html";
declare option output:html-version "5";
declare option output:media-type "text/html";
declare function local:traverse ($node as node()) {
typeswitch($node)
case document-node() return
$node/node() ! local:traverse(.)
case element() return
element { node-name($node) } {
$node/@*,
$node/node() ! local:traverse(.)
}
default return $node
};
local:traverse(doc('has-cdata.html'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment