Skip to content

Do not eat whitespaces when saving/loading find and replace settings

Due to the QT bug QTBUG-104130, whitespace-only text nodes are discarded. When I rename photos and videos with krename, a standard procedure I follow is this:

  1. Rename all files based on the [exifExif.Photo.DateTimeOriginal] value This provides file names that look like "2024:01:04 16:58:33.jpg"
  2. Then I use the find and replace functionality to replace " " (a single whitespace) with a "_" (underscore) and ":" with "-" (and some more rules to rename the videos that dont's have exif values).

Unfortunately, due to QTBUG-104130, I cannot save and load the settings that contain the rule with the whitespace, and every single time I have to re-add a bunch of rules manually.

The simple fix is to use a CDATA section instead of a TextNode. Got the idea from a QT developer's response in this thread:

https://www.qtcentre.org/threads/35692-QDomDocument-Eats-Up-My-Spaces

Note that according to the XML specification, it actually feels like CDATA is the correct way to go anyway in fields like find and replace that must be parsed literally as character data.

https://www.w3.org/TR/REC-xml/#sec-cdata-sect

Merge request reports

Loading