Skip to main content

Bug Tracker

Side navigation

#13805 closed bug (duplicate)

Opened April 21, 2013 01:25PM UTC

Closed October 08, 2013 01:23PM UTC

jQuery.parseHTML can't work as expeced

Reported by: KhalilCheung <khalilcheung@126.com> 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 /></a>

howerver, the result is:

<a title="xxx ></a>">xxx /></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

Attachments (0)
Change History (3)

Changed April 21, 2013 02:45PM UTC by gibson042 comment:1

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/

Changed October 08, 2013 01:22PM UTC by gibson042 comment:2

resolution: patchwelcome
status: closedreopened

Changed October 08, 2013 01:23PM UTC by gibson042 comment:3

resolution: → duplicate
status: reopenedclosed

Duplicate of #14370.