Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11753 closed bug (invalid)

Text similar to html tags are considered as html tags - text() AND/OR replaceWith()

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


This problem came up with a strange data which is similar to html tag eg., <form:0123>. Which actually denotes a identifier to the user. It appears like either text() or replaceWith() is handling this type of input wrongly. In IE 8: The text prior to this identifier and the identifier is ignored and is not rendered. In Firefox 12: The identifier <form:0123> is ignored and is not rendered.

Below is html code that I tried. <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script> </head> <body> <textarea id="searchresultsdata1">Text prior to identifer,&lt;b&gt;text after b&lt;/b&gt;</textarea><br/> <textarea id="searchresultsdata2">Text prior to identifer,&lt;b:0123&gt;text after b:0123</textarea><br/> <textarea id="searchresultsdata3"> Text prior to identifer,&lt;FORM:0123&gt;text after FORM:0123</textarea>


var tableData1 = window.jQuery("#searchresultsdata1").text(); window.jQuery("#searchresultsdata1").replaceWith(tableData1); var tableData2 = window.jQuery("#searchresultsdata2").text(); window.jQuery("#searchresultsdata2").replaceWith(tableData2); var tableData3= window.jQuery("#searchresultsdata3").text(); window.jQuery("#searchresultsdata3").replaceWith(tableData3);


Output in Internet explorer 8: Text prior to identifer,text after b text after b:0123 text after FORM:0123

Output in Firefox 12.0:

Text prior to identifer,text after b Text prior to identifer,text after b:0123 Text prior to identifer,text after FORM:0123

Change History (1)

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

The .replaceWith() method takes HTML, so your strings look like markup to it. You'll need to HTMLEncode the special characters. Since IE8 doesn't understand custom tags it's even worse there, but again it's already wrong so there's no guarantee of consistent output.

Note: See TracTickets for help on using tickets.