diff options
author | Isaac David <isacdaavid@isacdaavid.info> | 2017-10-07 19:34:01 -0500 |
---|---|---|
committer | Isaac David <isacdaavid@isacdaavid.info> | 2017-10-07 19:34:01 -0500 |
commit | a5de5ff031412c0319dc292d40ee60898d90e064 (patch) | |
tree | 93ebaab6d278d3f5eed7aeff2ec2e12aae0f8dcc /src | |
parent | 23abe8b1b17e9fc0236d40e9b6e5106a81af5ff3 (diff) |
blacklist.sh: update `normalize` and `get-reason` to reflect blacklist.txt
the blacklist has had a couple extra fields (ref, id) for some time, but
`libreblacklist` was never made aware of the change.
this updates test/lib-blacklist-test.sh for the same reason, and adds
a test for comment stripping under `it_normalizes_correctly()`.
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/lib/blacklist.sh | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh index 249ee89..6c507f4 100644..100755 --- a/src/lib/blacklist.sh +++ b/src/lib/blacklist.sh @@ -24,7 +24,11 @@ # Usage: blacklist-normalize <$file # Normalizes the syntax of the blacklist on stdin. blacklist-normalize() { - sed -e '/^#/d' -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/' + sed -r -e '/^#/d' \ + -e 's/^[^:]*$/&::::/' \ + -e 's/^[^:]*:[^:]*$/&:::/' \ + -e 's/^[^:]*(:[^:]*){2}$/&::/' \ + -e 's/^[^:]*(:[^:]*){3}$/&:/' } # Usage: blacklist-cat @@ -91,5 +95,5 @@ blacklist-get-rep() { # Usage: blacklist-cat | blacklist-get-reason # Prints only the reason field of the blacklist line(s) on stdin. blacklist-get-reason() { - blacklist-normalize | cut -d: -f3- + blacklist-normalize | cut -d: -f5- } |