Closed Bug 165323 Opened 22 years ago Closed 20 years ago

unclosed comment problem in strict mode with document.write()

Categories

(Core :: DOM: HTML Parser, defect)

defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: pbrennan, Assigned: harishd)

References

Details

(Keywords: regression)

Attachments

(5 files)

Hi. When using Mozilla 1.1 or Netscape 7, I have a problem with document.write. When I try to use document.write() to output "<!--", the <! is removed, and only "--" is written. If I insert another space, it outputs "< !--" just fine. document.write("<!--") works fine in IE, NS4.77, NS6, Opera, etc. We use this for a dynamic hiding technique like: <script type="text/javascript"> if (something) { document.write("<!-- hide"); } </script> ....stuff <!-- --> Any thoughts? Peter Brennan pbrennan@bridgewater.com
Browser, not engine ---> DOM Level 0
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Attached file testcase (quirks mode)
I cannot reproduce the problem with this testcase.
I _do_ see the problem in this case.
Attachment #97094 - Attachment is patch: false
Attachment #97094 - Attachment mime type: text/plain → text/html
Looks like standards comment parsing tries to deal with the unterminated comment somehow and fails... Over to parser.
Assignee: jst → harishd
Status: UNCONFIRMED → NEW
Component: DOM Level 0 → Parser
Ever confirmed: true
OS: Windows 2000 → All
QA Contact: desale → moied
Hardware: PC → All
Hmm, this is somewhat intended. Forget DHTML for now, and think about a static page. In a page we see "<!--", but no comment close. We understand that as "no comment", and treat treat everything from "<!--" (inclusive) as text. (There is a bug that we actually eat the "<!".) With document.write() we then have the problem that if you do several write() operations where one contains "<!--" but not comment close, what should we do? As you noted, we don't treat it as a comment at all. We just won't know which document.write() is going to be the last one. We cannot change the way we do parsing of static strict pages, because we know that would break sites (hide a lot of content). I am not sure what would be a good way to fix it for document.write(). Everything I can think of seems very difficult to do with high risk of regressions. The gain seems minimal, since pages that run into this could be written in other ways. What real sites are there that break because of this?
Keywords: regression
Summary: document.write removes <! chars → unclosed comment problem in strict mode with document.write()
*** Bug 186537 has been marked as a duplicate of this bug. ***
Every cite, that use this counter and have strict mode affected by this one. My own was affected (well... I solve this problem by changed js>11 to 11<js -- and now it at least terminated). I don't know any other standart compilant cite with this counter, I found one: http://www.pereplet.ru/
Depends on: 144902
I'm not sure this is a bug, actually. What happens is that we try to parse the comment in strict mode, but the document looks like this: <!-- blah.... <!-- --> more content etc... So, removing extraneous characters and whitespace, we are looking at: |<!-- -- -->| which is an unterminated comment. So we try to parse it as text, and end up losing the "<!" (which is a known bug) and parsing the comment as text. Am I missing anything here, or is this INVALID?
Marking INVALID per my last comment. I'll bet this regressed (as I see the regression keyword) when we enabled strict comment parsing, but that's just a guess.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: