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

Double escaping in qunit/reporter.js #147

Open
mmelvin0 opened this issue Jun 20, 2016 · 0 comments
Open

Double escaping in qunit/reporter.js #147

mmelvin0 opened this issue Jun 20, 2016 · 0 comments

Comments

@mmelvin0
Copy link

mmelvin0 commented Jun 20, 2016

The escapeInvalidXmlChars() function looks like this:

function escapeInvalidXmlChars(str) {
    return str.replace(/\&/g, "&")
        .replace(/</g, "&lt;")
        .replace(/\>/g, "&gt;")
        .replace(/\"/g, "&quot;")
        .replace(/\'/g, "&apos;")
        .replace(/`/g, "&grave;")
        .replace(/[$]/g, "&dollar;")
        .replace(/&/g, "&amp;");
}

Note you're double-escaping &. Also I'm not sure why grave accent and $ need to be escaped.

Couldn't this be simplified to this:

function escapeInvalidXmlChars(str) {
    return str.replace(/\&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/\>/g, "&gt;")
        .replace(/\"/g, "&quot;")
        .replace(/\'/g, "&apos;");
}
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