From a96d3ac6f8c10252f5ed01fb6574b6e34006e261 Mon Sep 17 00:00:00 2001 From: Peter Pentchev Date: Wed, 6 May 2020 18:29:52 +0300 Subject: Fix a Python implementation bug with values containing "=". --- debian/changelog | 9 +++++ debian/patches/python-value-eq.patch | 17 ++++++++ debian/patches/series | 2 + debian/patches/test-ini-eq.patch | 78 ++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 debian/patches/python-value-eq.patch create mode 100644 debian/patches/test-ini-eq.patch diff --git a/debian/changelog b/debian/changelog index 2305af2..398cff2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +confget (2.2.0-4+deb10u1) buster; urgency=medium + + * Fix the Python module's handling of values containing "=": + - add the test-ini-eq patch to add a test for such values + - add the python-value-eq patch to fix the problem + - Closes: #959887 + + -- Peter Pentchev Wed, 06 May 2020 19:12:09 +0300 + confget (2.2.0-4) unstable; urgency=medium * Use the test-name autopkgtest feature. diff --git a/debian/patches/python-value-eq.patch b/debian/patches/python-value-eq.patch new file mode 100644 index 0000000..bc1ec68 --- /dev/null +++ b/debian/patches/python-value-eq.patch @@ -0,0 +1,17 @@ +Description: python: fix processing of values containing "=". +Bug-Debian: https://bugs.debian.org/959887 +Origin: upstream; https://gitlab.com/confget/confget/-/commit/41b3a97b3d14a2b2f4365cc3fb4e5ea2497fe58c +Author: Peter Pentchev +Last-Update: 2020-05-06 + +--- a/python/confget/backend/ini.py ++++ b/python/confget/backend/ini.py +@@ -141,7 +141,7 @@ + regex=re.compile(r''' + ^ + \s* +- (?P \S+ ) ++ (?P [^\s=]+ ) + \s* = \s* + (?P .*? ) + \s* diff --git a/debian/patches/series b/debian/patches/series index 7cff224..af8a193 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,4 @@ python-no-executable.patch test-too-many-pypy.patch +test-ini-eq.patch +python-value-eq.patch diff --git a/debian/patches/test-ini-eq.patch b/debian/patches/test-ini-eq.patch new file mode 100644 index 0000000..1975b43 --- /dev/null +++ b/debian/patches/test-ini-eq.patch @@ -0,0 +1,78 @@ +Description: Add a test for INI files with values containing "=". +Origin: upstream; https://gitlab.com/confget/confget/-/commit/48c7942c59ec67ea0d9e670d8ef18d12054356d3 +Author: Peter Pentchev +Last-Update: 2020-05-06 + +--- a/t/01-get-values.t ++++ b/t/01-get-values.t +@@ -27,13 +27,18 @@ + [ -z "$CONFGET" ] && CONFGET='./confget' + [ -z "$TESTDIR" ] && TESTDIR='t' + +-echo '1..18' ++echo '1..19' + + + if [ ! -f "$TESTDIR/t1.ini" ]; then + echo "Bail out! No test file $TESTDIR/t1.ini" + exit 255 + fi ++ ++if [ ! -f "$TESTDIR/t4.ini" ]; then ++ echo "Bail out! No test file $TESTDIR/t4.ini" ++ exit 255 ++fi + v=`$CONFGET '-f' "$TESTDIR/t1.ini" '-s' 'a' 'key1' ` + res="$?" + if [ "$v" = 'value1' ]; then echo 'ok 1'; else echo "not ok 1 v is '$v'"; fi +@@ -88,3 +93,6 @@ + v=`env Q1='key4&key5=%09%09%20val%27ue5&key6' Q2='' QUERY_STRING='key1=value1&key2=%3Dvalue2%26&key3=%09%09%20val%27ue3' $CONFGET -t http_get '-s' 'Q2' 'key66' ` + res="$?" + if [ "$v" = '' ]; then echo 'ok 18'; else echo "not ok 18 v is '$v'"; fi ++v=`$CONFGET '-f' "$TESTDIR/t4.ini" '-s' 'x' 'key8' ` ++res="$?" ++if [ "$v" = 'key9=key10=key11' ]; then echo 'ok 19'; else echo "not ok 19 v is '$v'"; fi +--- a/t/defs/tests/01-get-values.json ++++ b/t/defs/tests/01-get-values.json +@@ -288,6 +288,22 @@ + }, + "setenv": true, + "stdin": null ++ }, ++ { ++ "args": { ++ "filename": "t4.ini", ++ "section": "x" ++ }, ++ "keys": [ ++ "key8" ++ ], ++ "xform": "", ++ "backend": "ini", ++ "output": { ++ "exact": "key9=key10=key11" ++ }, ++ "setenv": false, ++ "stdin": null + } + ] + } +--- /dev/null ++++ b/t/t4.ini +@@ -0,0 +1,16 @@ ++# Just a test file. Or something. ++# This file is hereby placed into the public domain. ++# ++# Test if confget can properly override "default" values with ++# ones specified in a named section. ++ ++both=default ++defonly=default ++ ++[a] ++aonly=b ++both=a ++aonly=a ++ ++[x] ++key8=key9=key10=key11 -- cgit v1.2.3