From 2c85caaff900ff508a1f3244918ba164cf712489 Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 28 Jan 2008 06:54:05 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3605 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/widget/WidgetHandler.class.php | 2 +- config/func.inc.php | 32 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/classes/widget/WidgetHandler.class.php b/classes/widget/WidgetHandler.class.php index c85c10960..75c8c019e 100644 --- a/classes/widget/WidgetHandler.class.php +++ b/classes/widget/WidgetHandler.class.php @@ -64,7 +64,7 @@ if(count($object_vars)) { foreach($object_vars as $key => $val) { if(in_array($key, array('body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right'))) continue; - $args->{$key} = urldecode($val); + $args->{$key} = utf8RawUrlDecode(utf8RawUrlDecode($val)); } } diff --git a/config/func.inc.php b/config/func.inc.php index f1f7d39dc..5ac341df6 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -470,4 +470,36 @@ if(function_exists('php_sapi_name') && php_sapi_name()=='cgi') return preg_replace('/index.php/i','',$_SERVER['PATH_INFO']); return preg_replace('/index.php/i','',$_SERVER['SCRIPT_NAME']); } + + function utf8RawUrlDecode ($source) { + $decodedStr = ""; + $pos = 0; + $len = strlen ($source); + while ($pos < $len) { + $charAt = substr ($source, $pos, 1); + if ($charAt == '%') { + $pos++; + $charAt = substr ($source, $pos, 1); + if ($charAt == 'u') { + // we got a unicode character + $pos++; + $unicodeHexVal = substr ($source, $pos, 4); + $unicode = hexdec ($unicodeHexVal); + $entity = "&#". $unicode . ';'; + $decodedStr .= utf8_encode ($entity); + $pos += 4; + } + else { + // we have an escaped ascii character + $hexVal = substr ($source, $pos, 2); + $decodedStr .= chr (hexdec ($hexVal)); + $pos += 2; + } + } else { + $decodedStr .= $charAt; + $pos++; + } + } + return $decodedStr; + } ?>