Closed Bug 620267 Opened 14 years ago Closed 14 years ago

All newlines immediately following a start <pre> tag get stripped

Categories

(Core :: DOM: HTML Parser, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: stanio, Assigned: neil)

References

Details

(Keywords: regression)

Attachments

(4 files)

User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b9pre) Gecko/20101219 Firefox/4.0b9pre
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b9pre) Gecko/20101219 Firefox/4.0b9pre

All newlines immediately following a start <pre> tag get ignored in HTML documents:

<pre>



Foo Bar</pre>

As far as I understand just the first newline following the start <pre> tag should be ignored <http://www.w3.org/TR/html5/grouping-content.html#the-pre-element>:

> In the HTML syntax, a leading newline character immediately following 
> the pre element start tag is stripped.

Reproducible: Always
Attached file Sample test
Renders:

foo
There should be three blank lines just before this line.

bar
[ Test ]

Hitting the "Test" (DOM value) button gives:

"There should be three blank lines just before this line.

"
Version: unspecified → Trunk
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86 → All
Regression range from Linux x86-64 nightlies is:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=83c887dff0da&tochange=d6bb0f9e9519
which is almost certainly the change to enable the HTML5 parser by default.
I'm surprised we didn't have test coverage for this. :-(
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED
It's not actually all that surprising, given the nature of the bug.

I just tried to reproduce this by copy/pasting the source of the attachment and could not reproduce.  Then I tried downloading the attachment from Bugzilla, and that does reproduce the bug.

The key seems to be the CR characters.  If I change the file to just use Unix newlines (LF only), everything works fine.  I would expect that's what our tests test....

When you do add a test for this, make sure to comment that it depends on the windows newlines?
blocking2.0: --- → ?
Sorry to spam the issue, but this was my source of finding the problem - does the text source from mail/news messages always contain CRLF line-endings, or it just happens to be on Windows?
> text source from mail/news messages

I mean with Thunderbird and SeaMonkey.
No idea what gunk mailnews generates!
The bug affects <textarea> too, of course. It's really weird; a textarea with N LFs before the first text (N >= 3) shows the text on the Nth line as expected; with a CR before the LFs you get the text on the N-1st line; with a CR after the first LF you get the text on the N-2nd line; with a CR after all the LFs you get the text on the N+1th line!
Attached patch Proposed patchSplinter Review
Assignee: hsivonen → neil
Attachment #499503 - Flags: review?(hsivonen)
Attachment #499503 - Flags: review?(hsivonen) → review+
See Bug 623288 for a similar (if not the same) problem.
I think it's pretty clear that this needs to block.  Please land this?
blocking2.0: ? → betaN+
Pushed changeset 6f18c950b3b6 to mozilla-central.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
The bit binary patch is useless for review. I'll attach a more reviewable copy of those bits.
Attachment #501620 - Flags: review?(jgriffin)
To see what's going on, you need to view this in a hex editor. :-(
Attachment #501620 - Flags: review?(jgriffin) → review+
Test landed:
http://hg.mozilla.org/mozilla-central/rev/a1b954e9fa32
Flags: in-testsuite? → in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: