The transfer handler installed by BasicListUI, inserts list values directly 
into the HTML clipboard representation without escaping HTML special 
characters, which is incorrect if the list values doesn't have `<html>` tag.
For example, a list item containing `<b>Hello</b>` should be displayed as 
literal text by the default renderer when it does not begin with `<html>`. 
Copying the item produces:
`<li><b>Hello</b>` so an HTML-aware application will see **Hello** in bold as 
receiving application interprets `<b>` as formatting tag, whereas without 
`<html>` tag the application should see it as literal `<b>Hello</b>`. 
Seeing only **Hello** in bold means the paste operation interpreted part of the 
text as formatting and hid the literal `<b> and </b>` characters

This is because `BasicListUI.ListTransferHandler.createTransferable()` appends 
each model value’s `toString() `directly after `<li>`. Consequently, literal 
tags become markup, and strings such as `&lt;`  gets decoded when pasted 
through the HTML flavor.
The fix is to make the HTML clipboard version represent the original text 
correctly by escaping html tags when explicit `<html>` tag is not used
while preserving intentional and explicit HTML values when `<html>` tag is used



---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - jcheck
 - 8393918: BasicListUI exports literal list text as unescaped HTML when copying

Changes: https://git.openjdk.org/jdk/pull/33814/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33814&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8393918
  Stats: 65 lines in 2 files changed: 65 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/33814.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33814/head:pull/33814

PR: https://git.openjdk.org/jdk/pull/33814

Reply via email to