Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
plist: tolerate spaces in keywords arguments
Baptiste Daroussin committed 5 years ago
commit 2cdf7ca0888a2630bf06e4b59b0cbacbd6b8b6a4
parent e5216cc
2 files changed +32 -3
modified libpkg/pkg_ports.c
@@ -1119,6 +1119,8 @@ parse_keyword_args(char *args, char *keyword)
		args++;
		if (*args == '\0')
			break;
+
		while (isspace(*args))
+
			args++;
		if (owner == NULL) {
			owner = args;
		} else if (group == NULL) {
@@ -1246,14 +1248,22 @@ plist_parse_line(struct plist *plist, char *line)
		keyword = line;
		keyword++; /* skip the @ */
		buf = keyword;
-
		while (!(isspace(buf[0]) || buf[0] == '\0'))
+
		while (!(isspace(buf[0]) || buf[0] == '\0')) {
+
			if (buf[0] == '(') {
+
				if ((buf = strchr(buf, ')')) == NULL) {
+
					pkg_emit_error("Malformed keyword %s, expecting @keyword "
+
				    "or @keyword(owner,group,mode)", keyword);
+
					return (EPKG_FATAL);
+
				}
+
			}
			buf++;
+
		}

		if (buf[0] != '\0') {
			buf[0] = '\0';
			buf++;
		}
-
		/* trim write spaces */
+
		/* trim spaces */
		while (isspace(buf[0]))
			buf++;
		pkg_debug(1, "Parsing plist, found keyword: '%s", keyword);
modified tests/frontend/create.sh
@@ -5,7 +5,7 @@
tests_init \
	create_from_plist \
	create_from_plist_set_owner \
-
	create_from_plist_set_group \
+
	create_from_plist_set_group_space \
	create_from_plist_gather_mode \
	create_from_plist_set_mode \
	create_from_plist_mini \
@@ -131,6 +131,25 @@ create_from_plist_set_group_body() {
		tar tvf test-1.txz
}

+

+
create_from_plist_set_group_space_body() {
+

+
	preparetestcredentials "(, bla,)"
+

+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -o ${TMPDIR} -m . -p test.plist -r .
+

+
	basic_validation
+
	atf_check \
+
		-o match:"-rw-r--r-- .*root[ /]+bla.* /file1$" \
+
		-e ignore \
+
		-s exit:0 \
+
		tar tvf test-1.txz
+
}
+

create_from_plist_gather_mode_body() {

	preparetestcredentials "(plop,bla,)"