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)
Core
DOM: HTML Parser
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
Comment 1•22 years ago
|
||
Browser, not engine ---> DOM Level 0
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
![]() |
||
Comment 2•22 years ago
|
||
I cannot reproduce the problem with this testcase.
![]() |
||
Comment 3•22 years ago
|
||
I _do_ see the problem in this case.
![]() |
||
Comment 4•22 years ago
|
||
![]() |
||
Updated•22 years ago
|
Attachment #97094 -
Attachment is patch: false
Attachment #97094 -
Attachment mime type: text/plain → text/html
![]() |
||
Comment 5•22 years ago
|
||
![]() |
||
Comment 6•22 years ago
|
||
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()
![]() |
||
Comment 8•22 years ago
|
||
*** Bug 186537 has been marked as a duplicate of this bug. ***
Comment 9•22 years ago
|
||
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/
Comment 10•20 years ago
|
||
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?
Comment 11•20 years ago
|
||
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.
Description
•