Bug Tracker

Opened 6 years ago

Closed 5 years ago

#13805 closed bug (duplicate)

jQuery.parseHTML can't work as expeced

Reported by: KhalilCheung <khalilcheung@…> Owned by:
Priority: undecided Milestone: None
Component: manipulation Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

I just wanna to use jQuery.parseHTML to parse a string into an array of DOM nodes. But I had encountered one problem about it.

Please refer to the test case http://jsfiddle.net/ACdXh/1/.

When it parse the string below:

<a title="xxx />">xxx /&gt;</a>

howerver, the result is:

<a title="xxx ></a>">xxx /&gt;</a>

I guess jQuery.parseHTML recognize the a tag as an empty element(sure it can't be), and as for non-empty elements of xhtml, end tags are required so it adds the corresponding end tag to it.

looking forward to your feedback.

thanks, Khalil

Change History (3)

comment:1 Changed 6 years ago by gibson042

Component: unfiledmanipulation
Resolution: patchwelcome
Status: newclosed

Thanks for the report! We can't really fix this without actually parsing content passed to manipulation method, but you can avoid it by escaping potentially dangerous attribute content: http://jsfiddle.net/ACdXh/3/

comment:2 Changed 5 years ago by gibson042

Resolution: patchwelcome
Status: closedreopened

comment:3 Changed 5 years ago by gibson042

Resolution: duplicate
Status: reopenedclosed

Duplicate of #14370.

Note: See TracTickets for help on using tickets.