Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12466 closed bug (notabug)

Firefox 15.0 attr()/html() with special char not working

Reported by: mathieu.de-kermadec@… Owned by:
Priority: low Milestone: None
Component: manipulation Version: 1.8.1
Keywords: Cc:
Blocked by: Blocking:

Description

Since last update of firefox, I have a problem working with xml attribute and special characters.

With this code:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html><head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
  var xmlstr = '<test><val attr="&lt;popo" /></test>';
  var xmldoc = $(xmlstr);
  xmldoc.find('val').attr('pilou', '<toto>&');
  console.log(xmldoc.html());
});
</script>
</body></html>

In firefox < 15:

<val attr="&lt;popo" pilou="&lt;toto&gt;&amp;"></val> 

In firefox 15:

<val pilou="<toto>&amp;" attr="<popo"></val>

In Chrome:

<val attr="&lt;popo" pilou="&lt;toto&gt;&amp;"></val> 

It seems that firefox 15 a problem escaping special characters in xml attributes.

Regards,

Mathieu De Kermadec

Change History (3)

comment:1 Changed 11 years ago by anonymous

Here is a jsFiddle to demonstrate: http://jsfiddle.net/F8Pgk/

comment:2 Changed 11 years ago by Timmy Willison

Component: unfiledmanipulation
Priority: undecidedlow
Status: newopen

Confirmed, but this may not be jQuery. Needs investigation.

comment:3 Changed 11 years ago by dmethvin

Resolution: notabug
Status: openclosed

$() does not parse XML and eventually that ends up being assigned to a div.innerHTML, so that is throwing the characters at the mercy of the HTML parser. This is a similar example not using jQuery: http://jsfiddle.net/F8Pgk/1/

If you believe there was a bug or behavior change in Firefox starting at version 15, please report it to them and post your bug ticket back here. I will mark as notabug because it doesn't appear to be a jQuery bug.

Note: See TracTickets for help on using tickets.