http://bugs.winehq.org/show_bug.cgi?id=7372
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |damjan.jov@gmail.com
--- Comment #51 from Damjan Jovanovic damjan.jov@gmail.com --- The first problem is that X11 apps seems have an extremely liberal interpretation of what "text/html" means. Using the readclipboard.c tool from bug 22987, and fetching TARGETS (which is the list of all possible data that can be pasted) and then the text/html target gives the following:
=============== Firefox 27.0.1: =============== $ ./readclipboard TARGETS TIMESTAMP TARGETS MULTIPLE SAVE_TARGETS text/html text/_moz_htmlcontext text/_moz_htmlinfo UTF8_STRING COMPOUND_TEXT TEXT STRING text/x-moz-url-priv
$ ./readclipboard text/html | hd 00000000 ff fe 3c 00 68 00 32 00 3e 00 43 00 61 00 6e 00 |..<.h.2.>.C.a.n.| 00000010 27 00 74 00 20 00 63 00 6f 00 70 00 79 00 20 00 |'.t. .c.o.p.y. .| 00000020 61 00 6e 00 64 00 20 00 70 00 61 00 73 00 74 00 |a.n.d. .p.a.s.t.| 00000030 65 00 3c 00 2f 00 68 00 32 00 3e 00 |e.<./.h.2.>.| 0000003c
which is an HTML fragment in UTF-16 LE with a leading byte order mark.
================= Konqueror 4.12.4: ================= $ ./readclipboard TARGETS text/plain UTF8_STRING STRING TEXT COMPOUND_TEXT text/html TARGETS MULTIPLE TIMESTAMP SAVE_TARGETS
$ ./readclipboard text/html | hd 00000000 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 20 50 |<!DOCTYPE html P| 00000010 55 42 4c 49 43 20 22 2d 2f 2f 57 33 43 2f 2f 44 |UBLIC "-//W3C//D| 00000020 54 44 20 58 48 54 4d 4c 20 31 2e 30 20 53 74 72 |TD XHTML 1.0 Str| 00000030 69 63 74 2f 2f 45 4e 22 20 22 44 54 44 2f 78 68 |ict//EN" "DTD/xh| 00000040 74 6d 6c 31 2d 73 74 72 69 63 74 2e 64 74 64 22 |tml1-strict.dtd"| 00000050 3e 0a 3c 62 6f 64 79 3e 3c 68 32 3e 43 61 6e 27 |>.<body><h2>Can'| 00000060 74 20 63 6f 70 79 20 61 6e 64 20 70 61 73 74 65 |t copy and paste| 00000070 3c 2f 68 32 3e 3c 2f 62 6f 64 79 3e |</h2></body>| 0000007c
which is a complete <body> to </body> HTML document containing the fragment, in UTF-8, without a byte order mark.
============= Midori 0.5.8: ============= $ ./readclipboard TARGETS TIMESTAMP TARGETS MULTIPLE SAVE_TARGETS UTF8_STRING COMPOUND_TEXT TEXT STRING text/plain;charset=utf-8 text/plain text/html
$ ./readclipboard text/html | hd 00000000 3c 6d 65 74 61 20 68 74 74 70 2d 65 71 75 69 76 |<meta http-equiv| 00000010 3d 22 63 6f 6e 74 65 6e 74 2d 74 79 70 65 22 20 |="content-type" | 00000020 63 6f 6e 74 65 6e 74 3d 22 74 65 78 74 2f 68 74 |content="text/ht| 00000030 6d 6c 3b 20 63 68 61 72 73 65 74 3d 75 74 66 2d |ml; charset=utf-| 00000040 38 22 3e 3c 68 32 20 73 74 79 6c 65 3d 22 66 6f |8"><h2 style="fo| 00000050 6e 74 2d 73 69 7a 65 3a 20 31 38 70 74 3b 20 63 |nt-size: 18pt; c| 00000060 6f 6c 6f 72 3a 20 72 67 62 28 30 2c 20 30 2c 20 |olor: rgb(0, 0, | 00000070 30 29 3b 20 66 6f 6e 74 2d 66 61 6d 69 6c 79 3a |0); font-family:| 00000080 20 27 62 69 74 73 74 72 65 61 6d 20 76 65 72 61 | 'bitstream vera| 00000090 20 73 61 6e 73 27 2c 20 76 65 72 64 61 6e 61 2c | sans', verdana,| 000000a0 20 61 72 69 61 6c 2c 20 68 65 6c 76 65 74 69 63 | arial, helvetic| 000000b0 61 2c 20 73 61 6e 73 2d 73 65 72 69 66 3b 20 66 |a, sans-serif; f| 000000c0 6f 6e 74 2d 73 74 79 6c 65 3a 20 6e 6f 72 6d 61 |ont-style: norma| 000000d0 6c 3b 20 66 6f 6e 74 2d 76 61 72 69 61 6e 74 3a |l; font-variant:| 000000e0 20 6e 6f 72 6d 61 6c 3b 20 6c 65 74 74 65 72 2d | normal; letter-| 000000f0 73 70 61 63 69 6e 67 3a 20 6e 6f 72 6d 61 6c 3b |spacing: normal;| 00000100 20 6c 69 6e 65 2d 68 65 69 67 68 74 3a 20 6e 6f | line-height: no| 00000110 72 6d 61 6c 3b 20 6f 72 70 68 61 6e 73 3a 20 32 |rmal; orphans: 2| 00000120 3b 20 74 65 78 74 2d 61 6c 69 67 6e 3a 20 2d 77 |; text-align: -w| 00000130 65 62 6b 69 74 2d 61 75 74 6f 3b 20 74 65 78 74 |ebkit-auto; text| 00000140 2d 69 6e 64 65 6e 74 3a 20 30 70 78 3b 20 74 65 |-indent: 0px; te| 00000150 78 74 2d 74 72 61 6e 73 66 6f 72 6d 3a 20 6e 6f |xt-transform: no| 00000160 6e 65 3b 20 77 68 69 74 65 2d 73 70 61 63 65 3a |ne; white-space:| 00000170 20 6e 6f 72 6d 61 6c 3b 20 77 69 64 6f 77 73 3a | normal; widows:| 00000180 20 32 3b 20 77 6f 72 64 2d 73 70 61 63 69 6e 67 | 2; word-spacing| 00000190 3a 20 30 70 78 3b 20 2d 77 65 62 6b 69 74 2d 74 |: 0px; -webkit-t| 000001a0 65 78 74 2d 73 69 7a 65 2d 61 64 6a 75 73 74 3a |ext-size-adjust:| 000001b0 20 61 75 74 6f 3b 20 2d 77 65 62 6b 69 74 2d 74 | auto; -webkit-t| 000001c0 65 78 74 2d 73 74 72 6f 6b 65 2d 77 69 64 74 68 |ext-stroke-width| 000001d0 3a 20 30 70 78 3b 20 22 3e 43 61 6e 27 74 20 63 |: 0px; ">Can't c| 000001e0 6f 70 79 20 61 6e 64 20 70 61 73 74 65 3c 2f 68 |opy and paste</h| 000001f0 32 3e 00 |2>.| 000001f3
which is the HTML fragment (with CSS?) and a leading <meta> tag, in UTF-8, with no byte order mark.
So X11 apps have made a real hash of the "text/html" target, and a clipboard implementation wishing to paste text/html must autodetect the charset and byte order, as well as be very liberal in parsing the HTML that comes out :-(.
Windows apps, by comparison, expect UTF-8 and a special format with the entire HTML document and headers giving offsets to the start and end of the fragment within the document (http://msdn.microsoft.com/en-us/library/aa767917%28v=vs.85%29.aspx).
Wine will correctly export text/html to X11 apps, as of commit 1bd13dec61ae693637c6514b9d35e29597f6ed6a by Vincent Povirk on 22 November 2009, which added X11DRV_CLIPBOARD_ExportTextHtml(), which convert's Windows's HTML to X11's text/html by cutting out the specified HTML fragment and giving that to the requesting X11 app.
But Wine doesn't fully/correctly support importing text/html from X11 apps, as it uses the generic X11DRV_CLIPBOARD_ImportClipboardData() function, which simply provides the data as given by the X11 app. This won't have the expected headers that Windows apps want to see, so importing will usually fail. Even if apps can deal with the absence of headers, Firefox uses UTF-16, while apps expect UTF-8. Even if this weren't a problem, Windows apps expect the full HTML document and a fragment within it, while Firefox only provides the fragment.
We could disable importing text/html in Wine, which would make Windows apps request plain text types instead and succeed, or fix importing text/html. The current behaviour is a bad mixture of unimplemented and broken behaviour.