Bug 19521 - <PRE> text copied from Safari - linefeeds are stripped when pasted in Mail
Summary: <PRE> text copied from Safari - linefeeds are stripped when pasted in Mail
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P1 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-06-12 10:42 PDT by Gibbons Burke
Modified: 2008-07-30 03:24 PDT (History)
2 users (show)

See Also:


Attachments
reduced html file with an example of the problem (1.81 KB, text/html)
2008-06-12 10:42 PDT, Gibbons Burke
no flags Details
Applescript which cleans up the text in the clipboard, works around issue (1.29 KB, text/osas)
2008-06-12 10:50 PDT, Gibbons Burke
no flags Details
Correct reduced html file (1.86 KB, text/html)
2008-06-12 10:55 PDT, Gibbons Burke
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gibbons Burke 2008-06-12 10:42:06 PDT
Plain pre-formatted text (<PRE>) copied from Safari, either in the page or in a form area, gets munged somehow in and when it is pasted straight into Mail.app, it is stripped of all the line feeds, so it becomes one big block of text.

Steps to reproduce:

1) Open attached "reduced.html" in Safari
2) Select the text presented in the view
3) copy it to the clipboard.
4) Go to mail and start a new message.
5) Click in the body area of the mail message
5) Paste the text.

If your default Compose style is "Rich text" the pasted material will look normal. But if you send it to someone using, say, Outlook on windows, the text will be stripped of line feeds when they get it. To see how it will appear to them, select "Make Plain Text" from the Format menu in Mail and it will turn the nice table into a munged block of nonsense.

If your default Compose style is "Plain text" then you'll see the text stripped of line feeds when you paste it into the new mail message.

When I follow the steps above using Firefox the problem does not occur. The text is fine.

Workaround: I have attached an applescript script which, if engaged before pasting in the text, will prevent the problem from occurring.
Comment 1 Gibbons Burke 2008-06-12 10:42:52 PDT
Created attachment 21660 [details]
reduced html file with an example of the problem
Comment 2 Gibbons Burke 2008-06-12 10:50:44 PDT
Created attachment 21661 [details]
Applescript which cleans up the text in the clipboard, works around issue

Hopeful this workaround will shed light on the nature of the issue with the text in Safari.
Comment 3 Gibbons Burke 2008-06-12 10:55:13 PDT
Created attachment 21662 [details]
Correct reduced html file

The previous version of the reduced.html was reduced too much. The problem appears to be the inclusion of the link to the TOP of the page in the PRE tags that causes this issue with the clipboard.
Comment 4 Gibbons Burke 2008-06-12 10:56:18 PDT
Comment on attachment 21660 [details]
reduced html file with an example of the problem

This version of the reduced.html file does not make the problem occur.
Comment 5 Gibbons Burke 2008-06-12 11:06:20 PDT
It appears that the <p> tag in the context of the <PRE></PRE> text in the reduced.html is the hinge. When the <p> tag is there and the text is copied to the clipboard, it causes the text to lose its line feeds. If the <p> tag is removed then Safari behaves as it did before (before 3.x) and like Firefox, that is, the text retains its shape when pasted into a plain text context in Mail.app, or at the final destination when pasted into a Rich text context and sent to others.
Comment 6 Chris Dary 2008-06-15 07:08:03 PDT
I cannot confirm this behavior in the latest nightly using attachment 21662 [details].

Can you check again with the latest nightly, Gibbons?
Comment 7 Gibbons Burke 2008-06-15 07:52:13 PDT
(In reply to comment #6)
> I cannot confirm this behavior in the latest nightly using attachment 21662 [details] [edit].
> 
> Can you check again with the latest nightly, Gibbons?

Yes, I can confirm that the problem manifests itself in the latest nightly build. I'm running on a PowerBook  G4.

The text appears fine when I paste it into a new Mail.app message, by default in Rich Text mode. But when I do a command-shift-T to convert the message to plain text, Mail munges the message, removing the line breaks, so that it appears as below:

Let variable values: @	=	SPX Date Day Nov->Apr May->Nov 04/30/1931 Thu -10.92 -30.88 04/29/1932 Fri -44.10 19.73 04/30/1937 Fri -4.64 -24.83 04/29/1938 Fri -20.81 34.36 04/28/1939 Fri -16.82 17.38 04/30/1940 Tue -4.99 -9.11 04/30/1941 Wed -15.97 2.04 04/30/1942 Thu -19.37 22.19 04/28/1944 Fri -0.34 7.67 04/30/1947 Wed -1.75 5.83 04/29/1949 Fri -10.85 9.38 04/29/1960 Fri -5.48 -1.80 04/30/1962 Mon -4.93 -13.37 04/29/1966 Fri -1.47 -11.93 04/30/1970 Thu -16.17 2.12 04/30/1973 Mon -4.13 1.23 04/30/1974 Tue -16.60 -18.17 04/29/1977 Fri -4.33 -6.20 04/30/1982 Fri -4.47 14.83 04/30/1984 Mon -2.14 3.77 04/30/1990 Mon -2.81 -8.10 04/29/1994 Fri -3.62 4.75 04/30/2001 Mon -12.59 -15.18 04/30/2008 Wed -10.57 NaN Avg -9.99 0.25 AvgPos NaN 11.18           AvgNeg -9.99 -13.96 PctPos 0.00 56.52 PctNeg 100.00 43.48 Maximum -0.34 34.36 Minimum         -44.10 -30.88 StdDev 9.61 15.74 ZStat -1.04 0.02 Variance 92.42 247.84 24 Occurrences

I made certain that I had no Input Managers in either the System or the User Libraries.
Comment 8 Alexey Proskuryakov 2008-06-15 17:33:06 PDT
This happens to me, too. Doesn't happen when pasting into other plain text documents (e.g. TextWrangler or Xcode), which makes me suspect that this is a Mail.app issue.
Comment 9 Alexey Proskuryakov 2008-06-15 17:34:10 PDT
<rdar://problem/6010128>
Comment 10 Robert Blaut 2008-07-30 03:24:06 PDT
(In reply to comment #8)
> This happens to me, too. Doesn't happen when pasting into other plain text
> documents (e.g. TextWrangler or Xcode), which makes me suspect that this is a
> Mail.app issue.
> 

I think the same.  I close this report, because it doesn't describe a bug in WebKit. Further action regarding Mail.app will be taken by Apple engineers via Radar report.