iniset did not handle the case of "|" in the value
to be injected. Fix this by replacing | with \000 (NULL).
Fixes bug #1258050
Change-Id: I8882c2f3f177ebdfa0c66270dbbc7fd50f30b065
| ... | ... |
@@ -741,8 +741,9 @@ function iniset() {
|
| 741 | 741 |
$option = $value |
| 742 | 742 |
" "$file" |
| 743 | 743 |
else |
| 744 |
+ local sep=$(echo -ne "\x01") |
|
| 744 | 745 |
# Replace it |
| 745 |
- sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file" |
|
| 746 |
+ sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
|
|
| 746 | 747 |
fi |
| 747 | 748 |
} |
| 748 | 749 |
|
| ... | ... |
@@ -136,6 +136,26 @@ else |
| 136 | 136 |
echo "iniget failed: $VAL" |
| 137 | 137 |
fi |
| 138 | 138 |
|
| 139 |
+# test pipe in option |
|
| 140 |
+iniset test.ini aaa handlers "a|b" |
|
| 141 |
+ |
|
| 142 |
+VAL=$(iniget test.ini aaa handlers) |
|
| 143 |
+if [[ "$VAL" == "a|b" ]]; then |
|
| 144 |
+ echo "OK: $VAL" |
|
| 145 |
+else |
|
| 146 |
+ echo "iniget failed: $VAL" |
|
| 147 |
+fi |
|
| 148 |
+ |
|
| 149 |
+# test space in option |
|
| 150 |
+iniset test.ini aaa handlers "a b" |
|
| 151 |
+ |
|
| 152 |
+VAL="$(iniget test.ini aaa handlers)" |
|
| 153 |
+if [[ "$VAL" == "a b" ]]; then |
|
| 154 |
+ echo "OK: $VAL" |
|
| 155 |
+else |
|
| 156 |
+ echo "iniget failed: $VAL" |
|
| 157 |
+fi |
|
| 158 |
+ |
|
| 139 | 159 |
# Test section not exist |
| 140 | 160 |
|
| 141 | 161 |
VAL=$(iniget test.ini zzz handlers) |