[php-src] master: Revert "fileinfo: Obey POSIX in pattern conversion"

From: Date: Sat, 24 Apr 2021 13:00:07 +0000
Subject: [php-src] master: Revert "fileinfo: Obey POSIX in pattern conversion"
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-115796@lists.php.net to get a copy of this message
Author: Anatol Belski (weltling) Date: 2021-04-24T14:59:53+02:00 Commit: https://github.com/php/php-src/commit/9b78000432438be3402d979883a027a06ee44252 Raw diff: https://github.com/php/php-src/commit/9b78000432438be3402d979883a027a06ee44252.diff Revert "fileinfo: Obey POSIX in pattern conversion" This reverts commit 343d1c2b1f2c6d267f1c63d17ca1c4d2349bf998. Also remove the incompatible test data for time being. The new line handling will need an extra fix. Signed-off-by: Anatol Belski <ab@php.net> Changed paths: D ext/fileinfo/tests/upstream/regex-eol.magic D ext/fileinfo/tests/upstream/regex-eol.result D ext/fileinfo/tests/upstream/regex-eol.testfile M ext/fileinfo/libmagic/softmagic.c Diff: diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 4ffb12253a6cd..c86524e31e623 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -2025,7 +2025,6 @@ public zend_string* convert_libmagic_pattern(const char *val, size_t len, uint32 j = 0; ZSTR_VAL(t)[j++] = '~'; - bool add_newline = false; for (i = 0; i < len; i++, j++) { switch (val[i]) { case '~': @@ -2038,21 +2037,6 @@ public zend_string* convert_libmagic_pattern(const char *val, size_t len, uint32 ZSTR_VAL(t)[j++] = '0'; ZSTR_VAL(t)[j] = '0'; break; - /* If POSIX regex class negates, make sure possible '\n' is taken into - account. For example "[^;]" is converted to "[^;]\n?" to obey POSIX. */ - case '^': - ZSTR_VAL(t)[j] = val[i]; - add_newline = (j >= 1 && '[' == ZSTR_VAL(t)[j-1]); - break; - case ']': - ZSTR_VAL(t)[j] = val[i]; - if (add_newline) { - t = zend_string_realloc(t, ZSTR_LEN(t) + 3, GC_TYPE_INFO(t) & IS_STR_PERSISTENT); - ZSTR_VAL(t)[j++] = '\\'; - ZSTR_VAL(t)[j++] = 'n'; - ZSTR_VAL(t)[j++] = '?'; - add_newline = false; - } default: ZSTR_VAL(t)[j] = val[i]; break; diff --git a/ext/fileinfo/tests/upstream/regex-eol.magic b/ext/fileinfo/tests/upstream/regex-eol.magic deleted file mode 100644 index 883d74c983e60..0000000000000 --- a/ext/fileinfo/tests/upstream/regex-eol.magic +++ /dev/null @@ -1,6 +0,0 @@ -## Ansible Vault files -0 string $ANSIBLE_VAULT Ansible Vault text ->&1 regex/1l [0-9]+(\.[0-9]+)+ \b, version %s ->>&1 regex/1l [^;]+$ \b, using %s encryption -!:mime application/ansible-vault -!:strength +60 diff --git a/ext/fileinfo/tests/upstream/regex-eol.result b/ext/fileinfo/tests/upstream/regex-eol.result deleted file mode 100644 index 5b1a7dbb3f906..0000000000000 --- a/ext/fileinfo/tests/upstream/regex-eol.result +++ /dev/null @@ -1 +0,0 @@ -Ansible Vault text, version 1.1, using AES256 encryption \ No newline at end of file diff --git a/ext/fileinfo/tests/upstream/regex-eol.testfile b/ext/fileinfo/tests/upstream/regex-eol.testfile deleted file mode 100644 index 607a8524b629c..0000000000000 --- a/ext/fileinfo/tests/upstream/regex-eol.testfile +++ /dev/null @@ -1,24 +0,0 @@ -$ANSIBLE_VAULT;1.1;AES256 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000

« previous php.cvs (#115796) next »