Closed Bug 38016 Opened 24 years ago Closed 24 years ago

– or ” breaks pasting as plaintext

Categories

(Core :: XUL, defect, P4)

x86
Linux
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: spam, Assigned: pavlov)

Details

Attachments

(1 file)

M16 linux 2000-050215
if text contains the signs – or ” (or equivalent "plaintext") it's
impossible to copy "beyond" them. Text gets selected, but when you paste it,
it's cut off.
Attached file try copy whole lines
Cc'ing nhotta, who might know something more about this.

Incidentally, I don't see the problem on linux when pasting from one composer
window into another (which is the only app I have which understands html paste
or html entities).  What are you pasting into?  What are you seeing cut off?
Turns out that this happens when pasting as *plaintext*, at least into some
apps, like xterm apps.

If you load the attachment in the editor and use the debug menu to show the
selection (Debug->Test Selection), you see that the output system is providing
the whole line, but it has a funny unprintable character in the middle, and
Linux apps get confused by this and won't deal with the rest of the line.

Naoki and I had a discussion about this a while back with regard to html output,
and the upshot was that the default behavior is to keep entities in the output
stream rather than encoding them to a form like – or  .  Unix systems
can probably live with that since we don't have many apps that handle html paste
anyway.  But the issue is still unresolved for plaintext: keeping the raw
characters does cause the problem described in this bug, but we can't turn them
into the html entity representation either.

Perhaps the best solution is that in the paste code, if we're ultimately going
to ascii rather than unicode (as is the case most of the time on Unix systems),
we need to strip out any characters which aren't legal ascii.  The clipboard
could do that as a postprocess, or it could set
nsIDocumentEncoder::OutputEncodeEntities and I could make the output sink do
it.  Cc'ing clipboard owners -- Pav, which solution would be easier?  Naoki and
Frank, does this solution sound acceptable for I18n users on Unix?
Summary: – or ” breaks copying → – or ” breaks pasting as plaintext
I was seeing one of two things happen when pasting into other apps:

1) initially, I was getting:
      ->>>>>>>>>>>>>> Read Clipboard from memory
      Transferable didn't support data flavor text/unicode (type = 31)
   but then this automagically stopped happening.

2) when pasting into (e.g.) gnotepad or a term, the paste would stop at 
   the location of the first entity in the selection
I would expect nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText()
(http://lxr.mozilla.org/seamonkey/source/widget/src/xpwidgets/nsPrimitiveHelpers.cpp#134)
which uses a charset converter to do this... Maybe there is a bug in the charset
encoder code?
I have a similar bug for inter application copy/paste 31797.
I am going to fix that by using one of the encoder function which substitute not 
converted characters.
Here's my patch for 31797.

Index: nsPrimitiveHelpers.cpp
===================================================================
RCS file: /cvsroot/mozilla/widget/src/xpwidgets/nsPrimitiveHelpers.cpp,v
retrieving revision 1.10
diff -c -r1.10 nsPrimitiveHelpers.cpp
*** nsPrimitiveHelpers.cpp	2000/04/17 08:21:12	1.10
--- nsPrimitiveHelpers.cpp	2000/05/03 20:11:45
***************
*** 164,169 ****
--- 164,170 ----
    if ( *outPlainTextLen ) {
      *outPlainTextData = NS_REINTERPRET_CAST(char*, 
nsAllocator::Alloc(*outPlainTextLen + sizeof(char)));
      if ( *outPlainTextData ) {
+       rv = 
encoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nsnull, 
'?');
        rv = encoder->Convert(inUnicode, &inUnicodeLen, *outPlainTextData, 
outPlainTextLen);
        (*outPlainTextData)[*outPlainTextLen] = '\0';          // null 
terminate. Convert() doesn't do it for us
      }


The other possibility is to use transliterate option of the entity encoder. 
Which translates a smart quote to double quote (0x22) for example.
http://lxr.mozilla.org/seamonkey/source/intl/unicharutil/idl/nsIEntityConverter.
idl
I checked in the fix for 31797.
Those characters which cannot be converted to ISO-8859-1 will be substituted 
with '?'.
reassigning to pavlov as p4 for m18
Assignee: trudelle → pavlov
Priority: P3 → P4
Target Milestone: --- → M18
mass-moving all bugs to m21 that are not dofood+, or nsbeta2+
Target Milestone: M18 → M21
 nhotta's fix basically fixes the problem of us not pasting enough... but I
think we should convert "smart quotes" in to normal quotes for ascii instead of
leaving them as question marks.  We should open another bug on that issue.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
bug 46729 filed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: