fix: HTML-escape file URLs to handle special characters in conflict and case clash dialogs#8847
Conversation
|
@copilot with this change the label now breaks with file paths containing double quotes instead |
You're absolutely right! I've fixed this by properly HTML-escaping the URLs using The fix converts characters like Fixed in commit 327d24a. |
|
/backport to stable-4.0 |
…ialogs Changed HTML anchor attribute delimiters from single quotes to double quotes in conflictdialog.cpp and caseclashfilenamedialog.cpp to properly handle file paths containing single quote characters. Fixes issue where clicking links for files with single quotes in their path would fail due to malformed HTML. Signed-off-by: GitHub Copilot <copilot@github.com> Co-authored-by: Rello <13385119+Rello@users.noreply.github.com>
Use Utility::escape() to HTML-escape file URLs before embedding them in anchor tags. This ensures both single quotes and double quotes (and other HTML special characters) are properly handled. The toHtmlEscaped() function converts: - ' to ' - " to " - & to & - < to < - > to > This fixes the issue where changing from single to double quote delimiters would break with double quotes instead. Signed-off-by: GitHub Copilot <copilot@github.com> Co-authored-by: nilsding <1809170+nilsding@users.noreply.github.com>
2fb75c0 to
a04811e
Compare
|
Artifact containing the AppImage: nextcloud-appimage-pr-8847.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|






Problem
File paths containing special HTML characters (single quotes
', double quotes", ampersands&, etc.) caused links in the conflict dialog and case clash dialog to break. When users clicked "Open local version" or "Open server version" for files with these characters in their path (e.g.,/some/path/folder'withsinglequote/file.ods), the links would not work.Root Cause
The HTML anchor tags embedded file URLs directly without escaping, causing the HTML parser to incorrectly interpret special characters in the URL as HTML syntax:
When a file URL contained special characters, the HTML would be malformed:
Solution
Properly HTML-escape the file URLs before embedding them in anchor tags using
Utility::escape(), which calls Qt'stoHtmlEscaped():This converts special HTML characters to their entity equivalents:
'→'"→"&→&<→<>→>Now all special characters are properly encoded:
Files Modified
src/gui/conflictdialog.cpp(added utility.h include, line 10; escaped URL, line 125)src/gui/caseclashfilenamedialog.cpp(added utility.h include, line 12; escaped URL, line 206)Testing
To reproduce and verify the fix:
mkdir "test'folder"andmkdir 'test"folder'touch "test'folder/testfile.txt"Impact
Fixes #
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.