Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not inherit LC_CTYPE locale from environment #5488

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Zend/tests/lc_ctype_inheritance.phpt
@@ -0,0 +1,23 @@
--TEST--
Do not inherit LC_CTYPE from environment
--SKIPIF--
<?php
if (!setlocale(LC_CTYPE, "de_DE", "de-DE")) die("skip requires de_DE locale");
?>
--ENV--
LC_CTYPE=de_DE
--FILE--
<?php

var_dump(bin2hex(strtoupper("\xe4")));
var_dump(preg_match('/\w/', "\xe4"));
var_dump(setlocale(LC_ALL, "de_DE", "de-DE") !== false);
var_dump(bin2hex(strtoupper("\xe4")));
var_dump(preg_match('/\w/', "\xe4"));
?>
--EXPECT--
string(2) "e4"
int(0)
bool(true)
string(2) "c4"
int(1)
3 changes: 3 additions & 0 deletions ext/snmp/snmp.c
Expand Up @@ -49,6 +49,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <locale.h>

#ifndef __P
#ifdef __GNUC__
Expand Down Expand Up @@ -1971,6 +1972,8 @@ PHP_MINIT_FUNCTION(snmp)
le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);

init_snmp("snmpapp");
/* net-snmp corrupts the CTYPE locale during initialization. */
setlocale(LC_CTYPE, "C");

#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE
/* Prevent update of the snmpapp.conf file */
Expand Down
1 change: 0 additions & 1 deletion ext/standard/basic_functions.c
Expand Up @@ -516,7 +516,6 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
* to the value in startup environment */
if (BG(locale_changed)) {
setlocale(LC_ALL, "C");
setlocale(LC_CTYPE, "");
zend_update_current_locale();
if (BG(locale_string)) {
zend_string_release_ex(BG(locale_string), 0);
Expand Down
Binary file modified ext/standard/tests/strings/strtolower-win32.phpt
Binary file not shown.
Binary file modified ext/standard/tests/strings/strtoupper1-win32.phpt
Binary file not shown.
1 change: 0 additions & 1 deletion main/main.c
Expand Up @@ -2133,7 +2133,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
zend_startup(&zuf);
setlocale(LC_CTYPE, "");
zend_update_current_locale();

#if HAVE_TZSET
Expand Down