Bug 395252 - kbuildsycoca5 breaks if "byte order mark" (first 3 magic bytes) present in plaintext file "clickMe.desktop"
Summary: kbuildsycoca5 breaks if "byte order mark" (first 3 magic bytes) present in pl...
Status: CONFIRMED
Alias: None
Product: frameworks-kservice
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.46.0
Platform: Netrunner Rolling Linux
: NOR minor
Target Milestone: ---
Assignee: David Faure
URL: https://kate-editor.org/2010/08/26/en...
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2018-06-11 17:06 UTC by fire f.
Modified: 2020-09-29 04:09 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fire f. 2018-06-11 17:06:19 UTC
The editor "Kate" offers to put 3 bytes "EF BB BF" in front of every text file optionally (enable under "configure Kate : open/save ").  

https://en.wikipedia.org/wiki/Byte_order_mark

The BOM is invisible in Kate and will break a lot of softwares. The "EFBBBF" is visible in Hex-editor "Okteta" only.

In particular,  kbuildsycoca5 v. 5.46.0   on a current June 2018 NetRunner ARCH Rolling-release distro  will break with a cryptic error message, if one used Kate with BOM enbabled to modify some  "clickMe.desktop" file in a trivial manner and the .desktop file will no longer work, e.g. in Dolphin.


kbuildsycoca5  should either manage to detect and work with a BOM or at least make a specific error message  e.g. :

"line 1 of the .desktop file contains a BOM as the first 3 bytes therefore kbuildsycoca5  is breaking. 
Please remove the BOM with a Hex editor such as Okteta."


The error is somewhat nasty since both Kate and Kompare will always hide the BOM so you don't see what the heck is going on.


How to reproduce:

in a bash shell in subdir    /home/YOURSELF/.local/share/kservices5/ServiceMenus/     run:

touch kfind.desktop
# now edit this kfind.desktop file with Kate and paste this content:

[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory
X-KDE-Priority=TopLevel
Actions=kfindhere;
Comment=KFind from here, very handy ! path is being preset
[Desktop Action kfindhere]
Name=KFind Files or Folders 
Name[es]=Buscar archivos/carpetas
Icon=kfind
Exec=kfind %u
# end of the kfind.desktop file is here

# enable BOM in Kate-settings and save the file with a BOM
# open kfind.desktop with okteta and verify that the first 3 bytes are EFBB... or something.
# run
kbuildsycoca5

# it will give an error in "line 1" because of the BOM
# remove the BOM using Okteta, all will be working fine again if run   "kbuildsycoca5"
Comment 1 fire f. 2018-06-11 17:13:31 UTC
alternatively, in Dolphin click and hover over KFind.desktop   in any subdir whatsoever, it will show on right-click unless a BOM is present.
Comment 2 fire f. 2018-06-11 17:49:56 UTC
find -type f |
while read file
do
    if [ "`head -c 3 -- "$file"`" == $'\xef\xbb\xbf' ]
    then
        echo "found BOM in: $file"
    fi
done

#  doesn't work with filenames that contain a line break
Comment 3 Christoph Feck 2018-06-11 19:32:52 UTC
If you mark this as a junior job, please add information where the code needs to be changed. The git repository is usually sufficient.
Comment 4 fire f. 2018-06-12 15:56:22 UTC
[Desktop Entry]

kate: byte-order-marker off;
# the above line avoids the problem in Kate, would still be nice to fix it properly

Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory
X-KDE-Priority=TopLevel
Actions=kfindhere;
Comment=KFind from here, very handy ! path is being preset
[Desktop Action kfindhere]
Name=KFind Files or Folders 
Name[es]=Buscar archivos/carpetas
Icon=kfind
Exec=kfind %u
# end of the kfind.desktop file is here