Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON reader fails on unescaped '<' or '&' #62

Open
wendellpiez opened this issue Aug 24, 2023 · 1 comment
Open

JSON reader fails on unescaped '<' or '&' #62

wendellpiez opened this issue Aug 24, 2023 · 1 comment

Comments

@wendellpiez
Copy link
Collaborator

The function currently does not escape open markup delimiters when writing contents, hence the literal XML written by the object-scraper comes out unreadable.

Solution is to regex/replace < and & in string content with their escaped forms, to represent them as literals.

A simple object for testing:

{ "key": "tiny bitto JSON < & >" }

comes out

<map xmlns="http://www.w3.org/2005/xpath-functions">
   <string key="key">tiny bitto JSON &lt; &amp; ></string>
</map>

Note the > is a red herring - it does not need to be escaped.

@wendellpiez
Copy link
Collaborator Author

when obj is a string --

obj.replaceAll('&','&amp;').replaceAll('<','&lt;')

goes around line 61 or so of json-reader.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant