From d0bdf88817eb4460544ae18afadaa3af2232b321 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 14 Apr 2017 13:04:13 +0100 Subject: [PATCH 3/3] Ensure hyphen/minus is treated as literal in regexes 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 --- doc/dbus-specification.xml | 2 +- test/test-dbus-launch-x11.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 7110be79..0f0ca5ae 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -3097,7 +3097,7 @@ The set of optionally-escaped bytes is: - [0-9A-Za-z_-/.\]. To escape, each + [-0-9A-Za-z_/.\]. To escape, each byte (note, not character) which is not in the set of optionally-escaped bytes must be replaced with an ASCII percent (%) and the value of the byte in hex. diff --git a/test/test-dbus-launch-x11.sh b/test/test-dbus-launch-x11.sh index be0f4f3c..8f049101 100755 --- a/test/test-dbus-launch-x11.sh +++ b/test/test-dbus-launch-x11.sh @@ -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 -- 2.11.0