Last Comment Bug 60619 - innerHTML escapes <>&' in script blocks and all html elements
: innerHTML escapes <>&' in script blocks and all html elements
Status: RESOLVED WORKSFORME
: testcase
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: All All
: P4 normal with 1 vote (vote)
: ---
Assigned To: general
: vidur (gone)
Mentors:
: 75543 75671 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2000-11-18 21:36 PST by Jesse Ruderman
Modified: 2013-04-04 13:53 PDT (History)
10 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
testcase (1.02 KB, text/html)
2000-11-18 21:37 PST, Jesse Ruderman
no flags Details
illustrate <,> escaped in script.innerHTML but not in document.body.innerHTML (1.14 KB, text/html)
2000-12-05 11:07 PST, Bob Clary [:bc:]
no flags Details
external script for test case 2 (76 bytes, application/x-javascript)
2003-10-13 22:42 PDT, Bob Clary [:bc:]
no flags Details
test case 2 (811 bytes, text/html)
2003-10-13 22:45 PDT, Bob Clary [:bc:]
no flags Details

Description Jesse Ruderman 2000-11-18 21:36:58 PST
innerHTML returns escaped versions of the <>& characters when they appear 
within <script> blocks.  (Steve mentioned this problem on 
http://www.bookmarklets.com/tools/new.html yesterday.)
Comment 1 Jesse Ruderman 2000-11-18 21:37:54 PST
Created attachment 19463 [details]
testcase
Comment 2 Bob Clary [:bc:] 2000-12-05 11:06:11 PST
Confirmed that script.innerHTML escapes < and > on 2000-12-04-04/Win2k.

Note however that < and > are is not escaped in script blocks if retrieved via
document.body.innerHTML. Attaching test case.
Comment 3 Bob Clary [:bc:] 2000-12-05 11:07:50 PST
Created attachment 20189 [details]
illustrate <,> escaped in script.innerHTML but not in document.body.innerHTML
Comment 4 Jeff Yates 2001-03-22 18:06:13 PST
I have created a javascript patch that fixes this problem.  I wrote the patch 
for the Range object (see bug 30838) and had to fix the innerHTML bug on 
orphaned nodes (see bug 70613).  When fixing that bug I seem to have also fixed 
this bug.

You can download a copy of the JavaScript patch at 
http://pbwizard.com/Moz%20Patches/RangePatch.zip.  This download also contains 
test cases that I used for testing my code.

Since this patch is implemented in JavaScript it will have to be converted to 
C++ for proper implementation.  If you have any questions or comments please e-
mail me at PBWiz@PBWizard.com.

Jeff Yates.
Comment 5 Brian 'netdragon' Bober 2001-06-01 02:18:08 PDT
I'll see what I can do. Not guaranteeing anything.
Comment 6 Kathleen Brade 2001-06-13 11:39:17 PDT
Extending summary to cover bugs which I will be resolving as duplicates of this 
bug.

Here is another test case:
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=30413
Comment 7 Kathleen Brade 2001-06-13 11:39:31 PDT
*** Bug 75543 has been marked as a duplicate of this bug. ***
Comment 8 Kathleen Brade 2001-06-13 11:40:01 PDT
*** Bug 75671 has been marked as a duplicate of this bug. ***
Comment 9 Asa Dotzler [:asa] 2001-12-03 10:40:15 PST
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 
(you can query for this string to delete spam or retrieve the list of bugs I've 
moved)
Comment 10 Fabian Guisset 2002-02-09 12:00:33 PST
Need more info here. Is this affecting real world web sites? Is it "bad"?
Tentatively marking P4, please speak up if you disagree. 
Sending to DOM Mozilla Extensions (innerHTML issue)
Removing dom2 keyword... innerHTML is not part of DOM2.
Comment 11 Vit Timchishin 2003-01-30 04:38:39 PST
I experience also a problem with assigning innerHTML. During assigning of
innerHTML of a just created (DOM) div, it converts & to &amp; (and do not touch
< or >).
Comment 12 Brian 'netdragon' Bober 2003-01-30 18:56:41 PST
Vit: Do you have a testcase?
Comment 13 Vit Timchishin 2003-01-31 02:32:03 PST
Sorry, false alarm. It was my problem.
Comment 14 Johnny Stenback (:jst, jst@mozilla.com) 2003-03-23 12:59:43 PST
Mass-reassigning bugs to dom_bugs@netscape.com
Comment 15 José Jeria 2003-05-28 04:33:01 PDT
Testcase 1 WFM build 2003052704, Windows 2000.
Comment 16 Jesse Ruderman 2003-10-12 00:42:22 PDT
WFM Gecko/20031009 Firebird/0.7+ (aebrahim)
Comment 17 Brian 'netdragon' Bober 2003-10-13 11:50:54 PDT
The first testcase works, and so do the first parts of the 2nd testcase, but the
part where it says "Fire loaded function" doesn't appear to work still. Is this
expected? Can you guys check the 2nd testcase and see if your results agree?
Comment 18 Jesse Ruderman 2003-10-13 17:30:21 PDT
Brian: that's bug 147581 (invalid).
Comment 19 Bob Clary [:bc:] 2003-10-13 22:40:22 PDT
Jesse, the second part of the test case is somewhat different from what is
claimed in bug 147581. In bug 147581, it is claimed that IE doesn't execute the
scripts and that is a good enough reason for us not to do so. In this case, an
inline script using DEFER is added via innerHTML and IE6 *will* execute the
functions. IE will also load an external script if it is DEFERred. I will attach
a test case.

So, bug 147581 should really be about supporting DEFER on scripts.

jst?
Comment 20 Bob Clary [:bc:] 2003-10-13 22:42:32 PDT
Created attachment 133245 [details]
external script for test case 2
Comment 21 Bob Clary [:bc:] 2003-10-13 22:45:09 PDT
Created attachment 133246 [details]
test case 2
Comment 22 Bob Clary [:bc:] 2003-10-13 22:52:21 PDT
test case 2 worked when running it as an example from the local disk, but
doesn't work running the external script from bugzilla. It appears the & in the
attachment url is escaped. Save test case 2 and it's script, edit to point to
the external file and it will work in IE.

Note You need to log in before you can comment on or make changes to this bug.


Privacy Policy