Closed
Bug 129508
Opened 24 years ago
Closed 21 years ago
Save As turns <p><table></table> into invalid <p><table></table></p>
Categories
(Core :: DOM: Serializers, defect)
Core
DOM: Serializers
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: cjmorland, Assigned: t_mutreja)
References
()
Details
(Whiteboard: [needs review])
Attachments
(3 files, 1 obsolete file)
|
3.62 KB,
text/html
|
Details | |
|
5.14 KB,
text/html
|
Details | |
|
1.98 KB,
patch
|
Details | Diff | Splinter Review |
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214
BuildID: 20020214
If you validate this page, it is legal. If you do "save as", the upload to the
validator, it will not verify.
Reproducible: Always
Steps to Reproduce:
1.validate the page (validator.w3.org)
2."save as" the page.
3.upload the page to the validator.
4.redo 1-3, using lynx.
Expected Results: Don't break working HTML!
Updated•24 years ago
|
Severity: enhancement → normal
OS: Linux → All
Comment 1•24 years ago
|
||
Comment 2•24 years ago
|
||
To DOM-to-text conversion. The parser allows <table> inside <p>, which the W3C
validator apparently does not. The source has:
<p><table></table>
So we output:
<p><table></table></p>
and the validator treats this as:
<p></p><table></table></p>
and barfs.
This all happens only when saving "web page, complete". And HTML-only save
works fine.
Assignee: law → harishd
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Component: File Handling → DOM to Text Conversion
Ever confirmed: true
OS: All → Linux
QA Contact: sairuh → sujay
Comment 3•24 years ago
|
||
Comment 4•24 years ago
|
||
Boris, I hope that your Nor -> Enh and All -> Linux was only for later loaded
form. Setting back (as my Win build does it too).
Severity: enhancement → normal
OS: Linux → All
| Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 6•24 years ago
|
||
Though comment in the code says 'table' to be required for fixing bug #43678, I
could not reproduce bug#43678 even after removing 'table' but as I don't have
much knowledge about this part of the code, I'm unable to see the actual side
effects, if any.
In case this is the wrong place to fix this bug, following diff can provide the
alternate solution:
Index: CNavDTD.cpp
===================================================================
RCS file: /cvsroot/mozilla/htmlparser/src/CNavDTD.cpp,v
retrieving revision 3.383
diff -r3.383 CNavDTD.cpp
2522a2523,2526
> if((eHTMLTag_table==aChild || eHTMLTag_tbody==aChild || eHTMLTag_tr==aChild
||
> eHTMLTag_th==aChild) && (eHTMLTag_p==aParent)) {
> result=PR_FALSE;
> }
Harish, I need your inputs here.
Tanu: P is allowed to contain a TABLE for backwards compatibility, even though
it violates the spec., so please don't remove that. It will break a lot of sites.
I don't understand your second diff. Could you explain that?
FYI: IMO, this problem is not easy to fix ( I may be wrong ) and fixing it in
CNavDTD is a bit dangerous ( it would change existing behavior ).
| Assignee | ||
Comment 8•24 years ago
|
||
>P is allowed to contain a TABLE for backwards compatibility, even though
>it violates the spec.
Then this bug should be a "WONTFIX" one. My second solution is also based on the
fact that P can NOT contain TABLE. Harish, you may like check the second diff to
see the impact. The Unified diff is as following:
RCS file: /cvsroot/mozilla/htmlparser/src/CNavDTD.cpp,v
retrieving revision 3.383
diff -u -r3.383 CNavDTD.cpp
--- CNavDTD.cpp 11 Apr 2002 23:50:39 -0000 3.383
+++ CNavDTD.cpp 20 Apr 2002 10:51:16 -0000
@@ -2520,6 +2520,10 @@
}
}
}
+ if((eHTMLTag_table==aChild || eHTMLTag_tbody==aChild || eHTMLTag_tr==aChild
||
+ eHTMLTag_th==aChild) && (eHTMLTag_p==aParent)) {
+ result=PR_FALSE;
+ }
return result;
}
Tanu: Why do you think the fix should be in CNavDTD? IMO, this should be fixed
in the plaintext serializer.
| Assignee | ||
Comment 10•24 years ago
|
||
Harish, my observation here was the same as comment#2, based on which I feel
that any such constraint should be part of the DTD. Fixing this in serializer
does not look good in the sense that the input DOM tree provided to serializer
is already allowing <table> to be present inside <p> and I feel during
serialization, we should not change the DOM at all.
Comment 11•24 years ago
|
||
>Harish, my observation here was the same as comment#2, based on which I feel
>that any such constraint should be part of the DTD.
Unfortunately, you cannot fix the DTD because it will break compatibilty.
However, we don't have that constraint in the plain text serializer and we're
free to correct the markup ( I think :-/ ). AFAIK, you can always add a rule, in
the plain text serializer, to close out P before opening up TABLE.
| Assignee | ||
Comment 12•24 years ago
|
||
Attachment #79255 -
Attachment is obsolete: true
| Assignee | ||
Comment 13•24 years ago
|
||
CC'ing Akkana and Jfrancis for review & comments.
Um, since the fix seems to be in the document encoder, I think you need to make
sure that it does not break XML serialization. What if I have arbitrary XML, no
namespaces or anything, like this: "<doc><p><table/></p></doc>"?
I would suggest that you try to push the fix to the serializers where there is
no harm. Or if it makes sense to have it in the document encoder, make sure that
it only applies to HTML and XHTML.
| Assignee | ||
Comment 15•24 years ago
|
||
I'm trying to fix it in nsHTMLContentSerializer but the preblem I'm facing is
with FixupNode() in nsDocumentEncoder.cpp (near line# 297):
if (mNodeFixup)
{
mNodeFixup->FixupNode(aNode, getter_AddRefs(node));
}
if (!node)
{
node = do_QueryInterface(aNode);
}
FixupNode is doing only a shallow copy and hence the node losses it's link with
the parent node. Is this shallow copy a requirement or it can be changed to
retain the link with the parent?
The shallow copy gives us performance, we really should try not to change that.
I don't have any good suggestions at this time... :/
Comment 17•24 years ago
|
||
Fixing this seems like a lot of pain with little gain.
We should emit the doc the DOM gives us. If it's illegal, that's the fault of
the parser (or of the editor if the dom has been editted). I can't see how it's
the serializers job to fix that.
As an example, what if there were more text after the table, and we have text
coloration style on the paragraph? In mozilla that text will be colored, since
we forgive the table inside the p. But after a save and reload, that text would
not be colored.
GIVEN that we allow illegal html to start with, that html should round-trip
through the serializer without degradation. If someone wants valid markup, they
can close their bloomin' p tags.
my 2¢
| Assignee | ||
Comment 18•24 years ago
|
||
I agree it's much work for no significant gain and it's definitely not the
serializer's job but mozilla promises the standards.
Had it been just a point to render an illegal/incomplete HTML it was worth
ignorance but the problem here is that "a legal HTML page is getting saved as
an illegal one" by mozilla.
Comment 19•24 years ago
|
||
We are going to need more differentiation here. If folks are save a page, they
will expect further viewings of the saved page to look the same. This proposed
fix will break that.
I don't see why it's a problem to save "quirks" html. That's the only kind we
view. If we had a strict viewing mode, then I would expect that to save as
strict html. But the two need to match.
How can it be non-compliant to save "illegal" html, but be compliant to treat
legal html as if it were quirky?
| Assignee | ||
Comment 20•24 years ago
|
||
Fix is meaningful and required only in 'Save As' with 'Web page, complete'
cases. In that case even if the saved HTML page looks different, it should be
fine as they are different in content itself.
Comment 21•24 years ago
|
||
If I'm understanding this bug, people are worried about the saved html being
illegal, but nobody seems to be worried about the fact that the dom tree is also
illegal. Isn't that a problem? Might that not cause problems for code which
accesses the dom and expect it to conform to the spec? Doesn't putting a
band-aid on the output system just hide the real problem, begging for it to come
back and bite us later?
| Assignee | ||
Comment 22•24 years ago
|
||
Akanna, I do agree with what you wrote and that's the reason I first tried
fixing it in DTD part itself but comment# 11 restricts that fix for backward
compatibility.
Probably band-aid patch would just mean that existing HTML sources that contain
<table> inside <p> would appear based on the earlier standards and if at all
mozilla happens to save that page, it will save with latest standards.
Comment 23•24 years ago
|
||
Some commentary on IRC tonight on how to solve the general case of these problems:
Suggestion was to save additional information in the DOM for each element node.
Amount of data storage could range from storing full text of start-tag and
end-tag with the node, to a more compressed version, i.e., end-tag could have 3
values, full (</generic identifier>), short (</>), or none (). Also a bit or two
to preserve the linefeeds discussed in bug 2750. Suggestion that maybe we only
add the augmentations to the DOM when creating it for editor; I know the parser
flag for view-source could probably be adapted to have an additional value
signaling a parse by the editor, but I don't know what would have to happen
downstream in content sink and beyond.
Comment 24•24 years ago
|
||
I'd rather not add overhead just to allow html that is valid but not interpreted
as valid to pass through Mozilla unchanged. The html and dom tree are bogus,
and Mozilla should be honest about that.
Can we remove the quirk that allows paragraphs to contain tables from standards
mode?
Summary: Save As turns legal HTML into illegal HTML → Save As turns <p><table></table> into invalid <p><table></table></p>
| Assignee | ||
Comment 25•23 years ago
|
||
*** Bug 206291 has been marked as a duplicate of this bug. ***
Comment 26•23 years ago
|
||
> Can we remove the quirk that allows paragraphs to contain tables from
> standards mode?
Done, see bug 91927. If it's "Save As" in Composer this bug is about then
it's worksforme.
Comment 27•21 years ago
|
||
This should be cosed:
wontfix in quirks mode,
Worksforme in strict mode (see bug 91927).
Comment 28•21 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050919 Firefox/1.4
Yep, it works correctly in standards mode. Wontfix sounds reasonable for quirks
mode.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•