Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14608 closed bug (notabug)

Wrong Textparsing with &reg (not ®)

Reported by: glueck@… Owned by:
Priority: undecided Milestone: None
Component: manipulation Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

If you try to write xxx&reg_xxx in a html context it will be shown as ® (...e®_b...)

Sample: $('#report').html("<div>rpt=sls_fleet_stat_tree&omit_olddata=true&ids=false&reg_by_month=false&cco_by_month=false</div>")

Change History (5)

comment:1 Changed 5 years ago by Frank Glück <glueck@…>

or try this: $('#report').html("&regby")

comment:2 Changed 5 years ago by Frank Glück <glueck@…>

but it is a little bit difficult:

$('#report').html('&reg &amp &euro &lt &gt &hearts &copy &trade &pound')

comment:3 Changed 5 years ago by gibson042

Component: unfiledmanipulation
Resolution: notabug
Status: newclosed

This is not under the control of jQuery, and not even a bug. See http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference for the relevant HTML5 character reference parsing logic:

Consume the maximum number of characters [immediately after the U+0026 AMPERSAND] possible, with the consumed characters matching one of the identifiers in the first column of the named character references table (in a case-sensitive manner).

Note that reg appears in the table, so the first 4 characters of &regby should be consumed and replaced by U+00AE REGISTERED SIGN (®).

comment:4 Changed 5 years ago by Frank Glück <glueck@…>

If the character reference is being consumed as part of an attribute, and the last character matched is not a U+003B SEMICOLON character (;), and the next character is either a U+003D EQUALS SIGN character (=) or an alphanumeric ASCII character, then, for historical reasons, all the characters that were matched after the U+0026 AMPERSAND character (&) must be unconsumed, and nothing is returned.

So try: $('#report').html('&reg=&reg;&regby')

comment:5 Changed 5 years ago by dmethvin

The point is, this is not a jQuery bug. If you have issues with the standard, contact the W3C and ask them to change the rules.

Note: See TracTickets for help on using tickets.