Subject: Re: bug#31149: 27.0.50; (gui-get-selection nil 'text/html) returns mis-decoded text

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 09 Nov 2021 04:44:17 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Stefan Monnier <[email-masked]> writes:
>
>> (gui-get-selection nil 'text/html)
>>
>> returns utf-16 text when the primary selection is owned by Mozilla, but
>> we decode it as latin-1 instead, so it looks like garbage.
>
> This should now be fixed on the trunk, and hopefully I didn't regress
> anything, but I have not regressed anything.  (I've only tested on
> Debian and Macos.)  Let me know whether I broke something.

It broke selection on Windows, so I've reverted and reopened this bug
report.

>From the discussion on emacs-devel:

> > > Does reverting 5e66c75e0 fix the issue?
> > 
> > I've reverted it now and will have to reexamine the problem before
> > attempting a new fix.
> 
> Whatever you do, don't decode the selection text on MS-Windows.  It is
> already decoded (see w32-get-clipboard-data), and
> selection-coding-system is UTF-16 on MS-Windows, so decoding a decoded
> string by that will not do anything useful ;-)
> 
> The existing code carefully side-steps the decoding by looking at the
> foreign-selection property on the string, which the Windows code
> doesn't set.  But your changes removed that test, and thus caused the
> clipboard text to be decoded on Windows.

So I'll be re-exploring this issue once I get my Windows VMs back up and
can do some testing on Windows, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no