Closed
Bug 51844
Opened 24 years ago
Closed 23 years ago
about:blank is invalid
Categories
(Core :: Networking, defect, P3)
Core
Networking
Tracking
()
VERIFIED
FIXED
mozilla0.9.5
People
(Reporter: ian, Assigned: Biesinger)
References
()
Details
Attachments
(2 files, 1 obsolete file)
726 bytes,
text/html
|
Details | |
690 bytes,
patch
|
bbaetz
:
review+
|
Details | Diff | Splinter Review |
The "about:blank" page is empty but tagged as text/html, and is thus invalid
and is causing the HTML parser to turn it into "<html><body></body></html>".
This is just as invalid, but whatever.
A fix for this would be as follows:
netwerk/protocol/about/src/nsAboutBlank.cpp, line 33:
- static const char kBlankPage[] = "";
+ static const char kBlankPage[] =
+ "<blank xmlns=\"http://www.mozilla.org/about\"/>";
netwerk/protocol/about/src/nsAboutBlank.cpp, line 49 (now 50):
- rv = NS_NewInputStreamChannel(&channel, aURI, in, "text/html",
+ rv = NS_NewInputStreamChannel(&channel, aURI, in, "text/xml",
nsCRT::strlen(kBlankPage));
...and then add the following 2 lines as file "about" in the root of the
www.mozilla.org webserver:
<!ELEMENT blank EMPTY>
<!ATTLIST blank xmlns CDATA #FIXED 'http://www.mozilla.org/about'>
This is untested.
Comment 1•24 years ago
|
||
Why do we currently use a blank text/html as opposed to
- blank text/plain
- nonblank, valid text/html (3.2? 4.01 transitional? 4.01 strict?)
- just nothing (would bug 5569 show up?)
Does it have something to do with JavaScript liking to use about:blank as a
scratchpad?
So do we think changing the type will cause any problems?
Comment 4•24 years ago
|
||
Many webpages and bookmarklets rely on about:blank being an html file so that
they can document.write to it. For example,
javascript:x=window.open("about:blank").document;x.write
("<html><head><title>foo</title></head><body>bar</body></html>");
Interestingly,
javascript:document.write
("<html><head><title>foo</title></head><body>bar</body></html>");
replaces the title of a normal webpage with "foo" in Mozilla (it doesn't in
IE), so it might be ok to replace the blank html page at about:blank with
<html><head><title></title></head><body></body></html>. I would want to be
sure that the original page is really being wiped by the first document.write,
though, because otherwise there might be more subtle problems for javascript
using about:blank.
Comment 5•24 years ago
|
||
If I load a .txt file and then document.write() to it, it becomes an html
file. So changing the MIME type for about:blank to text/plain probably
wouldn't cause problems for javascript. I'd be interested to know which MIME
type is best for performance (for opening a new window or for opening a new
window and document.write()ing to it).
Comment 7•23 years ago
|
||
Some web pages expect to be able to use DOM2 on about:blank in order to create
the new document. While changing the mime type might not break document.write,
it would break things like createTextNode, especially if the script assumes
that the document it's creating is HTML.
Assignee | ||
Comment 8•23 years ago
|
||
Assignee | ||
Comment 9•23 years ago
|
||
This patch changes the about:blank document to this:
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML//EN">
<html><head><title></title></head><body></body></html>
Which is a valid HTML 2.0 Document, according to validator.w3.org
What do you think? I tested if Jesse's Javascript still works, and it works as
expected.
Reporter | ||
Comment 10•23 years ago
|
||
Why 2.0?
Assignee | ||
Comment 11•23 years ago
|
||
Why a newer Version? 2.0 is certainly enough for such a simple document.
But if you want, I can also use:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Would you prefer HTML 4?
Or would you even suggest XHTML?
Reporter | ||
Comment 12•23 years ago
|
||
Because if the whole reason for it being something is that it will then be used by
sites to generate pages out of it, it should be the biggest quirks mode superset
possible, and that would be HTML 4.01 Transitional without a URI.
Assignee | ||
Comment 13•23 years ago
|
||
(strange, I don't get emails for changes to this bug...)
Hixie, I think the reason to change this is that currently it is invalid HTML,
not that it enables Quirks Mode.
I think if something is written into about:blank, whatever is written replaces
the current content. (Read Comment from Jesse Ruderman on 2000-11-18 20:38).
I did test if document.write to it really replaces the content, and it does.
So I think that Mozilla will look at the new content to determine whether to use
Quirks Mode.
Assignee | ||
Comment 14•23 years ago
|
||
I just checked it: Firstly, I applied my patch to make about:blank a HTML 2
document.
Then, I opened about:blank with JavaScript and wrote to it.
The Document (which had no doctype) was rendered in Quirks mode.
So, IMHO the best solution would be using the HTML 2.0 Doctype.
Or did I miss something?
Reporter | ||
Comment 15•23 years ago
|
||
If the document is totally overwritten by document.write, then why not use the
solution I proposed at the top of this bug?
If Quirks Mode vs Strict Mode doesn't matter, but we have to use HTML, why not use
the most up to date version of HTML? (HTML 4.01 Strict)
If Quirks Mode does matter, why not use the most up to date version of HTML that
triggers quirks mode? (HTML 4.01 Transitional without a URI in the DOCTYPE)
What's the advantage of using an obsolete DOCTYPE for our about:blank?
Assignee | ||
Comment 16•23 years ago
|
||
Well, I personally prefer to use the oldest Doctype for which the document is valid.
Making this an XML Document, which you suggested at the top, is imho not a good
solution (It would need the file at www.mozilla.org, correct?).
Using a text/plain file might be a good idea. It would also require the least
changes.
I did it the way I did because about:blank was already a HTML file, and I wanted
to change as little as possible, so I just made it a _valid_ HTML Document.
So, I would suggest either an empty text/plain "file", or a valid HTML File.
Opinions?
Reporter | ||
Comment 17•23 years ago
|
||
Using XML wouldn't need the file, no. That is purely optional. Using XML has the
advantage that the file is then an obscure joke.
Using text/plain seems sensible enough, if it works with JS. (Does it?)
I don't see any reason to use the oldest DOCTYPE for which the document is
valid.While this may have _some_ logic on the web, it is irrelevant here since
we know
that the UA will support the DOCTYPE we use if we use the most up-to-date one.
What advantage is there to using 2.0 over 4.01 ?
Assignee | ||
Comment 18•23 years ago
|
||
Assigning this bug to me and removing helpwanted, as I'm working on this.
Assignee: pavlov → cbiesinger
Keywords: helpwanted
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 19•23 years ago
|
||
Using an empty text/plain document is very bad.
This document would not be blank, but display like this:
<html><body></body></html>
(might not be exactly the same, but is certainly similar)
So, HTML 4.01 Strict seems to be the best solution. Objections?
I will attach a patch using HTML 4.01 Strict after I verified that this will
work correctly.
Assignee | ||
Comment 20•23 years ago
|
||
HTML 4.01 Strict doesn't work, quirks mode is never activated then after
document.write.
HTML 4.01 Transitional w/o URL works. Quirks mode is activated/deactivated
depending on the DOCTYPE. (I will attach my testcase here. It works in all
builds in which bug 93371 is fixed).
I will attach a patch which makes the document a valid HTML 4.01 Transitional
Document.
Assignee | ||
Comment 21•23 years ago
|
||
Assignee | ||
Comment 22•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #47136 -
Attachment is obsolete: true
Assignee | ||
Comment 23•23 years ago
|
||
Apply the patch by doing this:
cd mozilla/netwerk/protocol/about/src
patch -p0 < aboutpatch.diff
Afterwards, please remove one of the \" at the end of the line with "static
const char kBlankPage[]", I accidently added it.
Please test on other Platforms than windows, comment and r=.
Target Milestone: Future → mozilla0.9.5
Comment 24•23 years ago
|
||
Comment on attachment 49118 [details] [diff] [review]
Patch to make about:blank a valid HTML 4.01 Transitional Document
r=bbaetz after fixing the extra \"
Attachment #49118 -
Flags: review+
Comment 25•23 years ago
|
||
why is there not a </head> tag? and why do we need a <title> section?
Assignee | ||
Comment 26•23 years ago
|
||
</head>: I simply forgot it. Neither I nor bbaetz noticed that. And
validator.w3.org didn't complain either.
<title>: HTML Specification requires that <title> is present in a HTML Document.
Correct Patch would be:
Index: nsAboutBlank.cpp
===================================================================
RCS file: /cvsroot/mozilla/netwerk/protocol/about/src/nsAboutBlank.cpp,v
retrieving revision 1.19
diff -u -r1.19 nsAboutBlank.cpp
--- nsAboutBlank.cpp 2000/11/17 03:44:56 1.19
+++ nsAboutBlank.cpp 2001/09/12 18:54:20
@@ -30,7 +30,8 @@
NS_IMPL_ISUPPORTS1(nsAboutBlank, nsIAboutModule);
-static const char kBlankPage[] = "";
+static const char kBlankPage[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">"
+"<html><head><title></title></head><body></body></html>";
NS_IMETHODIMP
nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result)
Comment 27•23 years ago
|
||
sr=darin
Assignee | ||
Comment 28•23 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•