Open Bug 265803 Opened 20 years ago Updated 4 years ago

DOM->plain strips one space from the end of non-<PRE> lines

Categories

(Core :: DOM: Serializers, defect, P5)

defect

Tracking

()

People

(Reporter: russell, Unassigned)

Details

(Keywords: helpwanted)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1

Thunderbird version 0.7 (20040616)

Create a new mail message, in the body of the text type, replacing + with SPACE.
AB++
CD

Highlight both lines AB and CD and paste into notepad, wordpad or some other
program.  You should see that the number of spaces after AB is one less then the
number entered into Thunderbird.  Yet pasting back the text back into Mozilla
and it will put the correct number of spaces after AB.

Reproducible: Always
Steps to Reproduce:
1. Type "AB<space><space><enter>CD" into the text body
2. Highlight everything you just typed 
3. Copy to clipboard using any method you like
4. Open Notepad or Wordpad and paste the clipboard text

Actual Results:  
The pasted text was missing one space after AB

Expected Results:  
The pasted text should have included exactly the characters I typed, highlighted
and copied.
I see the reported symptom in Thunderbird 0.8, Win2K, only when using HTML mail 
compose; the plain text composer works as expected.  Also in Mozilla MailNews 
HTML mail compose, and in Composer.

The issue is that the HTML is copied to the clipboard in a variety of formats; 
the plain text version (as output by the DOM->text serializer) strips one space 
from the end of each line of text.

Try loading this HTML file into Mozilla:
======
<html><title></title><body>
<p>ab   <br><!-- three spaces -->
cd <br><!-- one space -->
ef<br><!-- zero spaces -->
gh</p><!-- zero spaces -->
</body>
======
The lines are displayed, when selected, as:
  ab_      <-- single EOL space apparent (three spaces collapsed to one in DOM)
  cd_      <-- and here
  ef       <-- no EOL space here (so the EOL spaces above are not an
  gh              effect of the <br> but of the spaces in the source

Pasted into a plain text editor, none of the lines have a trailing space.  Use 
Word's "Paste Special" function to choose between the various clipboard buffers, 
and you'll see the HTML buffer maintains the spaces but the unformatted buffer 
has stripped them.

However, if the text is formatted with <pre>, all the EOL spaces are preserved 
on display *and* on plain-text paste (true for <pre> text in the HTML editor, as 
well).  IE6 and Opera 7.5 (Win2K) preserve the spaces on the plain text.

This casts some light on bug 125928, but solving this bug will actually make 
that bug more visible.

Doesn't really appear related to bug 116083, altho the test case above behaves 
differently with the <p style="white-space:pre;"> than it does with either 
vanilla <p> or the <pre> tag.
Assignee: mscott → dom-to-text
Status: UNCONFIRMED → NEW
Component: Message Compose Window → DOM to Text Conversion
Ever confirmed: true
OS: Windows XP → All
Product: Thunderbird → Browser
Hardware: PC → All
Summary: Copy text ending with space-enter is not copied to clipboard correctly for all formats → DOM->plain strips one space from the end of non-<PRE> lines
Version: unspecified → Trunk
Keywords: helpwanted
Attached file Test case
(In reply to comment #1)
> Pasted into a plain text editor, none of the lines have a trailing space. 
                                   ~~~~

Rereading this, two and a half years later, I can't figure out what I was thinking here.  When I changed the title to "strips one space" I either must have observed something different than I describe here, or I must have been confused by the related symptom at bug 125928.


> the HTML buffer maintains the spaces but the unformatted buffer 
> has stripped them.

In Firefox 2.0, the HTML buffer contains the collapsed (DOM) spaces -- the line (within a <p>) that ends with three spaces is pasted with only one.  The plain-text buffer has zero spaces at the end of any line in a <p>.

<pre> maintains the spaces precisely, in both plain and HTMl buffers.

<p style="white-space:pre"> currently behaves exactly as <p> does (altho in this mode, the <br> tags cause the HTML rendering to double-space the lines).
Assignee: dom-to-text → nobody
QA Contact: dom-to-text

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: