]> granicus.if.org Git - php/commitdiff
Fixed bug #77338
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Dec 2018 16:11:27 +0000 (17:11 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Dec 2018 16:11:27 +0000 (17:11 +0100)
Set preg_options to 0 in php_pcre_get_compiled_regex(_ex). These
options are intended to be passed to pcre2_match. However, we do
not have any flags that actually need to be set during matching
(all relevant flags are set during compilation), and the preg_flags
value is used for PHP-specific flags instead.

This parameter should be removed entirely in master to avoid confusion.

NEWS
ext/pcre/php_pcre.c
ext/standard/tests/misc/bug77338.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 71d43a66e980e62112d56bd100b539e70a885cf9..6e2986886a23776625b3a8bab92fea3979de6ba2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #77339 (__callStatic may get incorrect arguments). (Dmitry)
 
+- PCRE:
+  . Fixed bug #77338 (get_browser with empty string). (Nikita)
+
 - SPL:
   . Fixed bug #77298 (segfault occurs when add property to unserialized empty
     ArrayObject). (jhdxr)
index ff86458fbfa98f0a0d212b04b198b8988bd2c848..a7c1a93646dc3c8f5acc8315585db074a1f4f1f6 100644 (file)
@@ -867,7 +867,7 @@ PHPAPI pcre2_code *pcre_get_compiled_regex(zend_string *regex, uint32_t *capture
        pcre_cache_entry * pce = pcre_get_compiled_regex_cache(regex);
 
        if (preg_options) {
-               *preg_options = pce ? pce->preg_options : 0;
+               *preg_options = 0;
        }
        if (capture_count) {
                *capture_count = pce ? pce->capture_count : 0;
@@ -884,7 +884,7 @@ PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capt
        pcre_cache_entry * pce = pcre_get_compiled_regex_cache(regex);
 
        if (preg_options) {
-               *preg_options = pce ? pce->preg_options : 0;
+               *preg_options = 0;
        }
        if (compile_options) {
                *compile_options = pce ? pce->compile_options : 0;
diff --git a/ext/standard/tests/misc/bug77338.phpt b/ext/standard/tests/misc/bug77338.phpt
new file mode 100644 (file)
index 0000000..241ad02
--- /dev/null
@@ -0,0 +1,81 @@
+--TEST--
+Bug #77338: get_browser with empty string
+--INI--
+browscap={PWD}/browscap.ini
+--FILE--
+<?php
+
+var_dump(get_browser(""));
+
+?>
+--EXPECT--
+object(stdClass)#1 (34) {
+  ["browser_name_regex"]=>
+  string(6) "~^.*$~"
+  ["browser_name_pattern"]=>
+  string(1) "*"
+  ["browser"]=>
+  string(15) "Default Browser"
+  ["version"]=>
+  string(1) "0"
+  ["majorver"]=>
+  string(1) "0"
+  ["minorver"]=>
+  string(1) "0"
+  ["platform"]=>
+  string(7) "unknown"
+  ["alpha"]=>
+  string(0) ""
+  ["beta"]=>
+  string(0) ""
+  ["win16"]=>
+  string(0) ""
+  ["win32"]=>
+  string(0) ""
+  ["win64"]=>
+  string(0) ""
+  ["frames"]=>
+  string(1) "1"
+  ["iframes"]=>
+  string(0) ""
+  ["tables"]=>
+  string(1) "1"
+  ["cookies"]=>
+  string(0) ""
+  ["backgroundsounds"]=>
+  string(0) ""
+  ["authenticodeupdate"]=>
+  string(1) "0"
+  ["cdf"]=>
+  string(0) ""
+  ["vbscript"]=>
+  string(0) ""
+  ["javaapplets"]=>
+  string(0) ""
+  ["javascript"]=>
+  string(0) ""
+  ["activexcontrols"]=>
+  string(0) ""
+  ["stripper"]=>
+  string(0) ""
+  ["isbanned"]=>
+  string(0) ""
+  ["wap"]=>
+  string(0) ""
+  ["ismobiledevice"]=>
+  string(0) ""
+  ["issyndicationreader"]=>
+  string(0) ""
+  ["crawler"]=>
+  string(0) ""
+  ["css"]=>
+  string(1) "0"
+  ["cssversion"]=>
+  string(1) "0"
+  ["supportscss"]=>
+  string(0) ""
+  ["aol"]=>
+  string(0) ""
+  ["aolversion"]=>
+  string(1) "0"
+}