diff --git a/abuild.in b/abuild.in index 462808e..95bbd26 100755 --- a/abuild.in +++ b/abuild.in @@ -969,8 +969,6 @@ git_last_commit_epoch() { get_maintainer() { if [ -z "$maintainer" ]; then maintainer=$(awk -F': ' '/# *Maintainer/ {print $2}' "$APKBUILD") - # remove surrounding whitespace - maintainer=$(echo "$maintainer" | xargs) fi } @@ -981,8 +979,10 @@ check_maintainer() { else # try to check for a valid rfc822 address case "$maintainer" in - *[A-Za-z0-9]*\ \<*@*.*\>) ;; - *) return 1 ;; + " "*|*" ") error "'$maintainer' has leading or trailing space"; return 1 ;; + \"*|*\") error "'$maintainer' has leading or trailing quote"; return 1 ;; + *\ \<*@*.*\>) ;; + *) error "'$maintainer' is not a valid rfc822 address"; return 1 ;; esac fi } diff --git a/tests/abuild_test b/tests/abuild_test index b5f22ec..7f8b3c1 100755 --- a/tests/abuild_test +++ b/tests/abuild_test @@ -27,7 +27,8 @@ init_tests \ abuild_package_size_nonzero \ abuild_amove \ abuild_doc \ - abuild_dev + abuild_dev \ + abuild_check_maintainer export ABUILD_SHAREDIR=$(atf_get_srcdir)/.. export ABUILD_CONF=/dev/null @@ -673,3 +674,24 @@ abuild_dev_body() { done test -L pkg/foo-dev/usr/lib/libfoo.so || atf_fail "libfoo.so failed" } + +abuild_check_maintainer_body() { + mkdir -p foo && cd foo + for m in "Test User 123 <123example.com>" \ + "foo" \ + "user@example.com" \ + " Leading Space " \ + "Trailing Space " \ + "Foo" \ + '"Quotes "'; do + printf "# Maintainer: %s\n%s\n" "$m" "pkgname=foo" > APKBUILD + atf_check -s not-exit:0 \ + -e match:"ERROR:" \ + abuild check_maintainer + done + + for m in "Test User <123@example.com>" "Foo O'Brian " "Ɓukasz Something "; do + printf "# Maintainer: %s\n%s\n" "$m" "pkgname=foo" > APKBUILD + atf_check abuild check_maintainer + done +}