Closed Bug 256731 Opened 22 years ago Closed 21 years ago

Bad tag inside phrase-element tags (EM, STRONG, VAR etc) fail them to close

Categories

(Core :: DOM: HTML Parser, defect)

x86
Windows 98
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: chalx, Assigned: mrbkap)

References

Details

Attachments

(3 files)

User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040806 Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040806 Bad tag: some unspecified opening-tag-like string: <tag> Phrase elements: EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, and ACRONYM Issued code (fragment, but works standalone too): Normal text ... <em>Phrase element <bad_tag> </em> ... Normal text again Problem: closing EM doesn't work while preferred with bad (unsupported) tag: all text to end is EMed. Reproducible: Always Steps to Reproduce: Open any page with detailed bad content Actual Results: Plain text ... Italic text ... Italic text Expected Results: Plain text ... Italic text ... Plain text Not issued code: - whith normal (specified) tag instead of bad one; - with any (same or not) closing bad tag after or instead of bad one; - with normal (not phrase-element) markup tags like I or B.
Attached file testcase —
Hmm... Shouldn't the residual style code handle this?
It probably should. Confirming (I see this on a week-old cvs build).
Status: UNCONFIRMED → NEW
Ever confirmed: true
So why does <span> work while <bad_tag> does not? For that matter, are there valid HTML tags that also don't work? Chances are this is an nsElementTable tweak if we can figure out what to tweak.
Not understanding most of the code here makes this a bit difficult to debug :-). Sorry if the following is basic knowledge and just repetition. Skip the next paragraph for my conclusion. I traced what's happening and I found that the root of the problem is that EM tags cannot close kFlowEntity tags. Thus nsHTMLTags::GetCloseTargetForEndTag stops when it sees an eHTMLTag_userdefined (which currently is a kFlowEntity -- going by parents, which seems to be how this system classifies tags). Then it returns eHTMLTag_unknown, and CNavDTD::HandleEndToken peters out. I checked this by making eHTMLTag_userdefined a 'kSpecial' tag, and the page then was parsed properly (this probably is *not* the fix). Anything that has a 'parent' of kFlowEntity should trigger this. See: http://lxr.mozilla.org/seamonkey/source/parser/htmlparser/src/nsElementTable.cpp#2090 and note <em> is phrase-level. Perhaps we need to special-case the userdefined tags or put them in another group?
*** Bug 265137 has been marked as a duplicate of this bug. ***
So the problem is that opening the userdefined tag doesn't close <em>, but closing <em> doesn't close the userdefined tag either, huh? I think having </phrase> close out userdefined tags should be ok, but it's a scary change... jst? peterv? rbs? heikki? Do you know anything about this stuff?
> I think having </phrase> close out userdefined tags should be ok me too. The only couple of bugs that I have seen with userdefined tags were bug 167493 (and related). In real life (TM), such tags happen in copy-paste (from M$ cruft bug 195260) or XBL -- all of which are well-formed. So the fix will be fine. There aren't significant pages that have come to depend on the existing buggy behavior.
Attached patch patch v1 — — Splinter Review
This allows phrasals to close userdefined tags (special casing them). I'm not entirely sure about style issues in this file (or where to put the test in the loop) but this made the most sense to me. This patch passes the parser regression tests, for what they're worth.
Assignee: parser → mrbkap
Status: NEW → ASSIGNED
Attachment #163261 - Flags: superreview?(bzbarsky)
Attachment #163261 - Flags: review?(rbs)
Comment on attachment 163261 [details] [diff] [review] patch v1 r=rbs
Attachment #163261 - Flags: review?(rbs) → review+
Comment on attachment 163261 [details] [diff] [review] patch v1 sr=bzbarsky. This is probably the safe way to do this, yes. Could you add this testcase to the parser regression tests, please? And for that matter, just generally add all the testcases you can find to them?
Attachment #163261 - Flags: superreview?(bzbarsky) → superreview+
Comment on attachment 163262 [details] regression testcase rbs, could you give me r+sr to check this in to the parser regression tests?
Attachment #163262 - Flags: superreview?(rbs)
Attachment #163262 - Flags: review?(rbs)
Comment on attachment 163262 [details] regression testcase You don't need r/sr for regression tests. Just check them in, in good faith.
Attachment #163262 - Flags: superreview?(rbs)
Attachment #163262 - Flags: review?(rbs)
Both the regression test and the patch have been checked in.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: