Bug 166756 - The file name in the header uses URL (percent) encoding
Summary: The file name in the header uses URL (percent) encoding
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.6.2 release
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Alin Andrei Abahnencei
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Writer-Header-Footer
  Show dependency treegraph
 
Reported: 2025-05-28 05:34 UTC by Peter
Modified: 2025-08-26 17:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
My test file. You can preview upper header to see UTF-8 codes. (11.40 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-28 05:41 UTC, Peter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter 2025-05-28 05:34:49 UTC
Description:
If the file name contains symbols and you paste it file name into the header footer (used Menu\Format\Page style\...\FileName fields), some of them - "#", "%", "[" and "]", printed or previewed as UTF-8 code: %23, %25, % 5B, %5D

Steps to Reproduce:
1. Create file with the symbol  "[", "]", "#", "%" in the file name.
2. Insert its FileName in the upper footer with "Menu\Format\Page style\Upper footer\Edit\FileName field".
3. Preview or print file.

Actual Results:
symbols "[" "]" "#" "%" printing or previewed as UTF-8 codes

Expected Results:
symbols "[" "]" "#" "%" printing or previewed as symbols


Reproducible: Always


User Profile Reset: No

Additional Info:
1) I have a file: "[1] name_of_file.xlsx", (or "*.ods" - it is not matter).
When I printed it, I saw that the characters "[" and "]" were printed as "%5B" and "%5D". As it turned out, this is also visible when previewing the page.

2) I created a file named: "1-=!@#$%^&*()_+|{}[] name_file.ods" and saw that symbols "#", "%", "[" and "]" previewing or printing in the header footer in UTF-8: %23, %25, %5B, %5D
Comment 1 Peter 2025-05-28 05:41:36 UTC
Created attachment 200988 [details]
My test file. You can preview upper header to see UTF-8 codes.
Comment 2 Mike Kaganski 2025-05-28 08:57:25 UTC
Code pointer: SvxExtFileField::GetFormatted in editeng/source/items/flditem.cxx. It should fix handling of SvxFileFormat::NameOnly and SvxFileFormat::NameAndExt, where it uses wrong decode mechanism.
Comment 3 Mike Kaganski 2025-06-26 08:29:18 UTC
Let me update the code pointer. It turns out, that Calc has a separate function for its fields content; look at ScHeaderEditEngine::CalcFieldValue.