Bug Tracker

Modify

Ticket #9843 (closed bug: worksforme)

Opened 2 years ago

Last modified 2 years ago

html() method can't handle HTML encoded characters [ampersand-style]

Reported by: shehriyari Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

Description

HOW TO REPEAT:
Let's say we have following piece of code:

var someVar = "<b>&quot;Don&39;t!&quot;</b>;
jQuery("#someDiv").html(someVar);

EXPECTED BEHAVIOUR:
#someDiv gets following content: <b>&quot;Don&39;t!&quot;</b>

WHAT HAPPENS:
Instead #someDiv gets following content: <b>&quot;Don&amp;39;t!&quot;</b>
As you can see, html() method handles ampersand-and-numbers-encoded-special-characters the way text() method does/should. &quot; character is rendered correctly, but &39; is not!

Change History

comment:1 Changed 2 years ago by shehriyari

Sample code @JsFiddle:

 http://jsfiddle.net/GRwP7/

comment:2 Changed 2 years ago by rwaldron

  • Priority changed from undecided to low
  • Resolution set to worksforme
  • Status changed from new to closed
  • Component changed from unfiled to manipulation

comment:3 Changed 2 years ago by timmywil

rwaldron beat me to it. That character code is invalid btw.

 http://jsfiddle.net/timmywil/GRwP7/3/

comment:4 Changed 2 years ago by shehriyari

@rwaldron: Point was numeric-encodings, not alpha ones. Your fix was irrelevant sorry.

@timmywil: He didn't actually. Thanks for pointing out my error. Apparently I missed the hash (#) sign.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.