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

Correct encode text #266

Open
apronin83 opened this issue Oct 22, 2020 · 0 comments
Open

Correct encode text #266

apronin83 opened this issue Oct 22, 2020 · 0 comments

Comments

@apronin83
Copy link

apronin83 commented Oct 22, 2020

You have incorrect coding of the text of the node and attribute.

Your code (dom.js):

function _xmlEncoder(c){
	return c == '<' && '&lt;' ||
         c == '>' && '&gt;' ||
         c == '&' && '&amp;' ||
         c == '"' && '&quot;' ||
         '&#'+c.charCodeAt()+';'
}

...

	case ATTRIBUTE_NODE:
		return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
	case TEXT_NODE:
		return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));

My code (dom.js):

function _xmlEncoder(c) {
    return c == '<' && '&lt;' ||
        c == '>' && '&gt;' ||
        c == '&' && '&amp;' ||
        c == '"' && '&quot;' ||
        c == "'" && '&apos;';
}

...

	case ATTRIBUTE_NODE:
		return buf.push(' ',node.name,'="',node.value.replace(/[&"<>\']/g,_xmlEncoder),'"');
	case TEXT_NODE:
		return buf.push(node.data.replace(/[&"<>\']/g,_xmlEncoder));
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