Closed Bug 284296 Opened 20 years ago Closed 3 years ago

DOMParser freezes Mozilla if the top element is html:script

Categories

(Core :: XML, defect)

x86
All
defect
Not set
critical

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: minghong, Unassigned)

References

Details

(Keywords: hang)

Attachments

(1 file)

573 bytes, application/xhtml+xml
Details
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1

DOMParser freezes when parsing a string that the top element is HTML script,
e.g. '<script xmlns="http://www.w3.org/1999/xhtml"/>'. Of course one can blame
me for parser an incorrect string. But my string is a well-formatted so it
should be parsed accordingly.

The bug is still reproducible on Mozilla 1.8b1.

P.S. If there is no xmlns, there is no problem (it is parsed as generic XML).
For other elements like p, table, hr, there is no problem too. HTML script seems
to be the only element that kills DOMParser.

Reproducible: Always

Steps to Reproduce:
1. Create a string like '<script xmlns="http://www.w3.org/1999/xhtml"/>'
2. Parse with DOMParser

Actual Results:  
The browser freezes when it loads the line with parseFromString().

Expected Results:  
Should parse accordingly if the string is well formatted.

I mark this bug as critical as it hangs the browser. But since usually people
parse a correct string to DOMParser, the bug may be less critical.
Attached file Test case
If it works, it should give an alert dialog with the text "script".

Disabled JavaScript if you don't want to hang your browser.
Confirm on GNU/Linux with Moz 1.8b1 too
confirming with win2k3 and Mozilla 20050226
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: hang
OS: Windows 2000 → All
So there seem to be two issues here:

1)  <script> as root doesn't load the script (see bug 88309)
2)  The DOMParser code spins in a tight loop calling ProcessPendingEvents() on
    the event queue it pushed until the page loads (which is forever, in this
    case, since the parser is blocked and will never unblock).  Is there a reason
    this can't use waitForEvent() and handleEvent()?  That will at least not
    freeze up the whole app (though the parseFromString call will still never
    return).
This is wholly or partially a dup of bug 88309. Making dependent for now.
Depends on: 88309
Well... The fact that this code busy-waits while we're parsing seems wrong even
if the parsing just takes "a while" instead of "forever".  Consider a slow
server such that fetching the script just takes 10-15 seconds....
*** Bug 318934 has been marked as a duplicate of this bug. ***
Assignee: xml → nobody
QA Contact: ashshbhatt → xml
Only a short glitch while moving the window; WFM on Firefox 4.0b7 (32 bit Windows 7).

Although this is a very old bug, I can not reproduce it on the latest Firefox Nightly 87 on MacOS 10.15. Closing this as resolved:worksforme, please re-open if it is still reproducible on your side. The string "script" was displayed on my end after loading the testcase.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: