]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Allow in-entry comments in SCHILY.acl.*
authorMartin Matuska <martin@matuska.org>
Sun, 25 Nov 2018 03:14:09 +0000 (04:14 +0100)
committerMartin Matuska <martin@matuska.org>
Sun, 25 Nov 2018 04:28:26 +0000 (05:28 +0100)
Fixes #1096

libarchive/archive_acl.c

index 6ce7ab66093a8dae33c9a04e2dc64f335d7a21a8..512beee1f734cbadbad6c8bd61aac271fb20b566 100644 (file)
@@ -1585,17 +1585,29 @@ next_field_w(const wchar_t **wp, const wchar_t **start,
 
        /* Scan for the separator. */
        while (**wp != L'\0' && **wp != L',' && **wp != L':' &&
-           **wp != L'\n') {
+           **wp != L'\n' && **wp != L'#') {
                (*wp)++;
        }
        *sep = **wp;
 
-       /* Trim trailing whitespace to locate end of field. */
-       *end = *wp - 1;
-       while (**end == L' ' || **end == L'\t' || **end == L'\n') {
-               (*end)--;
+       /* Locate end of field, trim trailing whitespace if necessary */
+       if (*wp == *start) {
+               *end = *wp;
+       } else {
+               *end = *wp - 1;
+               while (**end == L' ' || **end == L'\t' || **end == L'\n') {
+                       (*end)--;
+               }
+               (*end)++;
+       }
+
+       /* Handle in-field comments */
+       if (*sep == L'#') {
+               while (**wp != L'\0' && **wp != L',' && **wp != L'\n') {
+                       (*wp)++;
+               }
+               *sep = **wp;
        }
-       (*end)++;
 
        /* Adjust scanner location. */
        if (**wp != L'\0')
@@ -1646,7 +1658,7 @@ archive_acl_from_text_l(struct archive_acl *acl, const char *text,
        ret = ARCHIVE_OK;
        types = 0;
 
-       while (text != NULL  &&  *text != '\0') {
+       while (text != NULL &&  *text != '\0') {
                /*
                 * Parse the fields out of the next entry,
                 * advance 'text' to start of next entry.
@@ -2057,23 +2069,30 @@ next_field(const char **p, const char **start,
        *start = *p;
 
        /* Scan for the separator. */
-       while (**p != '\0' && **p != ',' && **p != ':' && **p != '\n') {
+       while (**p != '\0' && **p != ',' && **p != ':' && **p != '\n' &&
+           **p != '#') {
                (*p)++;
        }
        *sep = **p;
 
-       /* If the field is only whitespace, bail out now. */
-       if (**p == '\0') {
+       /* Locate end of field, trim trailing whitespace if necessary */
+       if (*p == *start) {
                *end = *p;
-               return;
+       } else {
+               *end = *p - 1;
+               while (**end == ' ' || **end == '\t' || **end == '\n') {
+                       (*end)--;
+               }
+               (*end)++;
        }
 
-       /* Trim trailing whitespace to locate end of field. */
-       *end = *p - 1;
-       while (**end == ' ' || **end == '\t' || **end == '\n') {
-               (*end)--;
+       /* Handle in-field comments */
+       if (*sep == '#') {
+               while (**p != '\0' && **p != ',' && **p != '\n') {
+                       (*p)++;
+               }
+               *sep = **p;
        }
-       (*end)++;
 
        /* Adjust scanner location. */
        if (**p != '\0')