[phpldapadmin] [PATCH] Don't set LC_CTYPE based on Accept-Language header

Ali Polatel <[email protected]> Thu, 15 Aug 2013 16:13:43 +0300
Newsgroups gmane.comp.ldap.davedap
Message-ID <10ec9302faf9a3107ab0bec13929fa8d712009d4.1376572361.git.ali.polatel@ozguryazilim.com.tr>
LC_CTYPE affects character classification and conversion in unexpected
ways. Moreover, setting it based on Accept-Language header breaks
phpldapadmin based sites for Accept-Language = 'tr'. An example breakage
results in the following error output:

Fatal error: Call to undefined method Tree::getInstance() in /path/to/lib/page.php on line 227

This is a longstanding bug in PHP, references:
https://bugs.php.net/bug.php?id=35050
https://bugs.php.net/bug.php?id=18556

The only workaround is setting LC_CTYPE to 'C' unconditionally.

Note: This shouldn't affect phpLDAPadmin's usage of locales in any way.

Signed-off-by: Ali Polatel <[email protected]>
---
 lib/common.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/common.php b/lib/common.php
index 1ab1672..727afc3 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -264,6 +264,12 @@ if ($app['language'] == 'auto') {
 				putenv('LANG='.$lang); # e.g. LANG=de_DE
 				$lang .= '.UTF-8';
 				setlocale(LC_ALL,$lang); # set LC_ALL to de_DE
+				# LC_CTYPE affects character classification and conversion in unexpected ways.
+				# Note: This is a longstanding bug in PHP (and affects Accept-Language: tr )
+				# References:
+				#  https://bugs.php.net/bug.php?id=35050
+				#  https://bugs.php.net/bug.php?id=18556
+				setlocale(LC_CTYPE,'C');
 				bindtextdomain('messages',LANGDIR);
 				bind_textdomain_codeset('messages','UTF-8');
 				textdomain('messages');
-- 
1.8.3.4


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
______________________________________
phpLDAPadmin development mailing list.
To unsbuscribe: https://lists.sourceforge.net/lists/listinfo/phpldapadmin-devel
http://phpldapadmin.sourceforge.net/