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

/ is escaped but should NOT be escaped #36

Open
GoogleCodeExporter opened this issue Apr 30, 2015 · 0 comments
Open

/ is escaped but should NOT be escaped #36

GoogleCodeExporter opened this issue Apr 30, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

This results in xml-files that looks ugly like this:

...
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
...

The only characters that has to be escaped are: <, &, >, ", '
Also ' should be replaced with &apos;
See: 
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#En
tities_representing_special_characters_in_XHTML

Replacement code:

    function escapeXmlChars(str) {
        if(typeof(str) == "string")
            return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
        else
            return str;
    }

Also the unescapeXmlChars should handle any escaped character (unicode and 
named) and not a small predefined set.

Original issue reported on code.google.com by david.gr...@gmail.com on 5 Feb 2015 at 1:34

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

No branches or pull requests

1 participant