pjfanning opened a new pull request, #1505:
URL: https://github.com/apache/poi/pull/1505

   Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=70292
   
   The user name in the FILESHARING record (`stUNUsername`) is an 
XLUnicodeString (cch, fHighByte, rgb). `FileSharingRecord` read `fHighByte` but 
ignored it and always read 8-bit characters, so a write-protected .xls saved by 
Excel with a non-latin user name (e.g. Korean) failed with 
`LeftoverDataException: Initialisation of record 0x5B(FileSharingRecord) left 3 
bytes remaining`. `serialize()`/`getDataSize()` had the same assumption, so 
`writeProtectWorkbook(password, username)` wrote broken records for such names.
   
   Changes:
   - read the name as UTF-16LE when bit 0 of `fHighByte` is set
   - write it with `StringUtil.writeUnicodeStringFlagAndData` and size it with 
`StringUtil.getEncodedSize` (16-bit only when the name has characters above 
0xFF)
   - drop the now-unused `field_3_username_unicode_options` field
   - new `TestFileSharingRecord` (8-bit, UTF-16LE, empty, Latin-1 names)
   - `TestBugs.bug70292` opens and round-trips the reporter's sample 
(`test-data/spreadsheet/70292.xls`, password to modify "test"), plus a 
`writeProtectWorkbook` round trip with a Korean user name
   
   Based on the patch by JEONGHO attached to the bug.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to