diff options
author | Sergei Turchanov <turchanov@farpost.com> | 2019-08-29 17:29:19 +1000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-12-20 11:22:59 +0100 |
commit | c62cd9a43ad97aa279615b21f7cb5f1646f52d80 (patch) | |
tree | 2cf838ada7ac80c90d24f7337faedf1049287902 /ext/fileinfo/tests | |
parent | cbb0efaeeb265ff8026dee1d049d57a8d2b5c133 (diff) | |
download | php-git-c62cd9a43ad97aa279615b21f7cb5f1646f52d80.tar.gz |
Fix #74170: locale information change after mime_content_type
Some functions in libmagic (distributed with fileinfo extension) perform this sequence of calls:
func() {
setlocale(LC_TYPE, "C")
.. do some work ..
setlocale(LC_TYPE, "")
}
It effectively resets LC_TYPE if it that was set before the function call.
To avoid manipulations with current locale at all, the problematic functions
were modified to use locale-independent functions.
Diffstat (limited to 'ext/fileinfo/tests')
-rw-r--r-- | ext/fileinfo/tests/bug74170.phpt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/fileinfo/tests/bug74170.phpt b/ext/fileinfo/tests/bug74170.phpt new file mode 100644 index 0000000000..9e3cbd982b --- /dev/null +++ b/ext/fileinfo/tests/bug74170.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #74170 locale information change after mime_content_type +--SKIPIF-- +<?php +if (!class_exists('finfo')) + die('skip no fileinfo extension'); +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (setlocale(LC_CTYPE, 'ru_RU.koi8r') === false) + die('skip ru_RU.koi8r locale is not available'); +?> +--FILE-- +<?php +var_dump(setlocale(LC_CTYPE, 'ru_RU.koi8r')); +var_dump(nl_langinfo(CODESET)); +var_dump(mime_content_type(__DIR__ . '/resources/test.ppt')); +var_dump(nl_langinfo(CODESET)); +--EXPECT-- +string(11) "ru_RU.koi8r" +string(6) "KOI8-R" +string(29) "application/vnd.ms-powerpoint" +string(6) "KOI8-R" |