]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Ensure hyphen/minus is treated as literal in regexes
authorSimon McVittie <smcv@collabora.com>
Fri, 14 Apr 2017 12:04:13 +0000 (13:04 +0100)
committerSimon McVittie <smcv@debian.org>
Tue, 18 Apr 2017 11:46:20 +0000 (12:46 +0100)
Each U+002D HYPHEN-MINUS in [0-9A-Za-z_-/.\] is treated as a member of a
range. The third one, which appears to have been intended to be a
literal, is part of an empty range because the starting point
U+005F LOW LINE is greater than the endpoint U+002F SOLIDUS, resulting
in at least some grep implementations not considering U+002D, U+002F
or U+005F to match the pattern. This resulted in one of the
dbus-launch tests being unintentionally skipped when it used a
regex based on the one in the spec.

regex(7) suggests "To include a literal '-' [in a bracketed character
set], make it the first or last character".

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100686

doc/dbus-specification.xml
test/test-dbus-launch-x11.sh

index 7110be79cb6c7d2d7ed65f3eb98afdffa5e2fe04..0f0ca5ae7546bc49885ecc35c40303114c4da9af 100644 (file)
         <listitem>
           <para>
             The set of optionally-escaped bytes is:
-            <literal>[0-9A-Za-z_-/.\]</literal>. To escape, each
+            <literal>[-0-9A-Za-z_/.\]</literal>. To escape, each
             <emphasis>byte</emphasis> (note, not character) which is not in the
             set of optionally-escaped bytes must be replaced with an ASCII
             percent (<literal>%</literal>) and the value of the byte in hex.
index be0f4f3c446dd7ab280305d1c70f1a84d3adcc46..8f049101f3e3965ff0052164f64981eb9713d4ab 100755 (executable)
@@ -198,7 +198,7 @@ test_xdg_runtime_dir () {
     export XDG_RUNTIME_DIR="$workdir"
     fake_uuid="ffffffffffffffffffffffffffffffff"
 
-    if echo "$workdir" | grep '[^0-9A-Za-z_-/.]'; then
+    if echo "$workdir" | grep '[^-0-9A-Za-z_/.]'; then
         test_num=$(($test_num + 1))
         echo "ok ${test_num} # SKIP - $workdir would need escaping"
         return