ogradyjp / ajaxslt

Automatically exported from code.google.com/p/ajaxslt
Other
0 stars 0 forks source link

XML escaping functions only escape first occurrence of each markup character #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Test the xmlEscapeText function with this string: Im <b>bold</b>!

What is the expected output? What do you see instead?
I expect it to produce: Im &lt;b&gt;bold&lt;/b&gt;!
However this is what is produced: Im &lt;b&gt;bold</b>!

What version of the product are you using? On what operating system?
I am using version 0.5 on a PC.

Please provide any additional information below.
I believe that the function needs to be modifed from this:
function xmlEscapeText(s) {
  return ('' + s).replace(/&/, '&amp;').replace(/</, '&lt;').
    replace(/>/, '&gt;');
}

To this:
function xmlEscapeText(s) {
  return ('' + s).replace(/&/g, '&amp;').replace(/</g, '&lt;').
    replace(/>/g, '&gt;');
}

That way all the < & and > are found in the string.

I dont know if this is the behavior that you are wanting.

Original issue reported on code.google.com by lea...@gmail.com on 3 Dec 2006 at 5:39

GoogleCodeExporter commented 9 years ago
Don't know how that crept in. Sure your solution is right. Fixing.

Original comment by steffen....@gmail.com on 15 Dec 2006 at 3:25

GoogleCodeExporter commented 9 years ago
Fixed in release-0-6.

Original comment by steffen....@gmail.com on 15 Dec 2006 at 8:45