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

RESOLVED FIXED

Status

()

Core
HTML: Parser
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: Stanimir Stamenkov, Assigned: neil@parkwaycc.co.uk)

Tracking

({regression})

Trunk
regression
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(blocking2.0 betaN+)

Details

Attachments

(4 attachments)

(Reporter)

Description

7 years ago
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
(Reporter)

Comment 1

7 years ago
Created attachment 498630 [details]
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.

"
(Reporter)

Updated

7 years ago
Version: unspecified → Trunk

Updated

7 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression, regressionwindow-wanted
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.
Keywords: regressionwindow-wanted
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: --- → ?
(Reporter)

Comment 5

7 years ago
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?
(Reporter)

Comment 6

7 years ago
> text source from mail/news messages

I mean with Thunderbird and SeaMonkey.
No idea what gunk mailnews generates!
(Assignee)

Comment 8

7 years ago
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!
(Assignee)

Updated

7 years ago
(Assignee)

Comment 9

7 years ago
Created attachment 499503 [details] [diff] [review]
Proposed patch
Assignee: hsivonen → neil
Attachment #499503 - Flags: review?(hsivonen)
Attachment #499503 - Flags: review?(hsivonen) → review+
(Reporter)

Comment 10

7 years ago
See Bug 623288 for a similar (if not the same) problem.
(Assignee)

Updated

7 years ago
Duplicate of this bug: 623288
I think it's pretty clear that this needs to block.  Please land this?
blocking2.0: ? → betaN+
(Assignee)

Comment 13

7 years ago
Pushed changeset 6f18c950b3b6 to mozilla-central.
Status: ASSIGNED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Created attachment 501620 [details] [diff] [review]
Add tests with CRLF, CR and escaped LF

The bit binary patch is useless for review. I'll attach a more reviewable copy of those bits.
Attachment #501620 - Flags: review?(jgriffin)
Created attachment 501621 [details]
Content corresponding to the git binary patch

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+
Duplicate of this bug: 591988
You need to log in before you can comment on or make changes to this bug.