Bug 70742 - xdg-desktop-menu improperly check for vendor prefix on Estonian locale
Summary: xdg-desktop-menu improperly check for vendor prefix on Estonian locale
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: 1.1.0
Hardware: All Linux (All)
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-21 22:35 UTC by marmarek
Modified: 2014-05-04 13:54 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description marmarek 2013-10-21 22:35:12 UTC
On Estonian locale this can happen:
xdg-desktop-menu: filename 'Uss-vm.directory' does not have a proper vendor prefix
A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated with a dash ("-"). An example filename is 'example-Uss--vm.directory'
Use --novendor to override or 'xdg-desktop-menu --manual' for additional info.

The reason is usage of [a-zA-Z] in check_vendor_prefix function, without specifying explicit locale. In case of Estonian, 'z' isn't the last letter...

Simple check:
$ echo 'w' | LC_COLLATE=C grep -q '[a-zA-Z]'; echo $?
0
$ echo 'w' | LC_COLLATE=et_EE grep -q '[a-zA-Z]'; echo $?
1

It should either use explicit locale, or use '[[:alpha:]]' instead. Not sure which is better (and more compliant with the standard).
Comment 1 Rex Dieter 2013-10-22 12:50:53 UTC
Thanks for the excellent report and diagnosis.

In a perfect world [[:alpha:]] would be the way to go, but for compatibility's sake, LC_COLLATE=C may be safer and more portable.

I'll try to review the whole code base this coming week, to ensure there are no other gotcha's like this one.
Comment 2 Rex Dieter 2013-10-24 20:50:28 UTC
The code in question:

check_vendor_prefix()
{
    file_label="$2"
    [ -n "$file_label" ] || file_label="filename"
    file=`basename "$1"`
    case "$file" in
       [a-zA-Z]*-*)
         return
         ;;
    esac
Comment 3 Rex Dieter 2013-10-24 21:36:40 UTC
Considering this code, (re)setting LC_ vars doesn't seem viable without rewriting.

Replacing
[a-zA-Z]*-*)
with
[[:alpha:]]*-*)

seems to work.

Re-reading
http://standards.freedesktop.org/menu-spec/menu-spec-latest.html#merge-algorithm

where it mentions vendor prefix, I see no mention of locale either. :(
Comment 5 Elan Ruusamäe 2014-05-04 06:54:57 UTC
is the [[:alpha:]] construct posix? do all shells support it? what shells you tested with?
Comment 6 Rex Dieter 2014-05-04 13:54:45 UTC
Yes (according to bash man page at least), I don't know, bash, respectively


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.