Skip to content

Commit

Permalink
Added check for backticks to prevent quoting in the unix
Browse files Browse the repository at this point in the history
type processing
  • Loading branch information
MARTIMM committed Dec 26, 2016
1 parent 2a62427 commit 4c4906d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion META.info
Expand Up @@ -12,5 +12,5 @@
"Config::DataLang::Refine": "lib/Config/DataLang/Refine.pm6"
},
"source-url": "git://github.com/MARTIMM/config-datalang-refine.git",
"version": "0.4.5"
"version": "0.4.6"
}
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -24,8 +24,8 @@ build: off

test_script:
# - prove -v --merge --exec "perl6 -Ilib" xt/wpath.t
- prove -v --merge --exec "perl6 -Ilib" t/
# - prove -v --merge --exec "perl6 -Ilib" t/300-refine-locations.t
- prove -v --merge --exec "perl6 -Ilib" t/

# fetch repository as zip archive
shallow_clone: true
Expand Down
2 changes: 2 additions & 0 deletions doc/CHANGES.md
Expand Up @@ -4,6 +4,8 @@ See [semantic versioning](http://semver.org/). Please note point 4. on
that page: ***Major version zero (0.y.z) is for initial development. Anything may
change at any time. The public API should not be considered stable.***

* 0.4.6
* Added check for even number of backticks to prevent quoting in the unix type processing C-UNIX-OPTS-T1 and C-UNIX-OPTS-T2. Spaces outside backticks must be quoted manually.
* 0.4.5
* Bugfixes in pathnames on windows
* 0.4.4
Expand Down
Binary file modified doc/Refine.pdf
Binary file not shown.
12 changes: 11 additions & 1 deletion lib/Config/DataLang/Refine.pm6
Expand Up @@ -288,6 +288,13 @@ class Config::DataLang::Refine:auth<https://github.com/MARTIMM> {
}
}

# Check for backticks(`), in Unix these can hold other commands. The line
# is checked for an even number of backticks. When there are spaces in
# the line the user must add the quoting to the line if necessary.
when not ?((m:g/ '`'/).elems +& 0x01) {
$entry = ($k.chars == 1 ?? "-$k" !! "--$k=" ) ~ "$v";
}

when /\s/ {
$entry = ($k.chars == 1 ?? "-$k" !! "--$k=" ) ~ "'$v'";
}
Expand All @@ -307,7 +314,6 @@ class Config::DataLang::Refine:auth<https://github.com/MARTIMM> {
for $o.kv -> $k, $v {

$entry = '';

given $v {
# should not happen
when Hash {
Expand Down Expand Up @@ -340,6 +346,10 @@ class Config::DataLang::Refine:auth<https://github.com/MARTIMM> {
}
}

when not ?((m:g/ '`'/).elems +& 0x01) {
$entry = ($k.chars == 1 ?? "-$k" !! "--$k=" ) ~ "$v";
}

when /\s/ {
$entry = ($k.chars == 1 ?? "-$k" !! "--$k=" ) ~ "'$v'";
}
Expand Down
11 changes: 9 additions & 2 deletions lib/Config/DataLang/Refine.pod6
Expand Up @@ -261,7 +261,7 @@ string used to join elements of an array, this is a ',' by default.
Bool k=True k=True
k=False <removed>
Array k=1,2,3 k=1,2,3
special text k='v' k='v'
spaced text k='v' k='v'
Any k=v k=v
Simple results
Expand All @@ -284,10 +284,17 @@ together with a '&' character. All strings will be encoded for the first
Bool --k --k
--nok <removed>
Array --k=1,2,3 --k=1,2,3
text with '`' --k=v --k=v
spaced text --k='v' --k='v'
Any --k=v --k=v
All single letter keys get only one dash on front like -k or -k=v. The
B<Note 1>: The values are also checked for backticks(`) because in Unix these can
hold other commands. However, a command can contain spaces which will then be
quoted. To prevent that the value is checked for an even number of backticks.
When there are spaces in the value outside these backticks the user must add the
quotes manually if necessary.
B<Note 2>: All single letter keys get only one dash on front like -k or -k=v. The
mode C-UNIX-OPTS-T2 does the same but gathers all single character keys without
values together prefixed with a dash. E.g. --key, -l, -m, -t=1 becomes --key,
-lm, -t=1
Expand Down

0 comments on commit 4c4906d

Please sign in to comment.