[Phpfreechat-svn] SF.net SVN: phpfreechat: [1142] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-23 21:02:54
|
Revision: 1142 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1142&view=rev Author: gpinzone Date: 2007-08-23 14:02:56 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Fixed issue with shortening URL when escaped HTML characters were being split improperly. Modified Paths: -------------- trunk/src/pfctools.php trunk/src/pfcurlprocessing.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-08-23 19:40:15 UTC (rev 1141) +++ trunk/src/pfctools.php 2007-08-23 21:02:56 UTC (rev 1142) @@ -437,4 +437,22 @@ } } +/** + * html_entity_decode + * For users prior to PHP 4.3.0 + */ +if (!function_exists('html_entity_decode')) +{ + function html_entity_decode($string) + { + // replace numeric entities + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string); + // replace literal entities + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + return strtr($string, $trans_tbl); + } +} + ?> \ No newline at end of file Modified: trunk/src/pfcurlprocessing.php =================================================================== --- trunk/src/pfcurlprocessing.php 2007-08-23 19:40:15 UTC (rev 1141) +++ trunk/src/pfcurlprocessing.php 2007-08-23 21:02:56 UTC (rev 1142) @@ -61,10 +61,12 @@ function pfc_shorten_url($url) { - $len = strlen($url); - $short_url = ($len > 40) ? substr($url, 0, 30) . "..." . substr($url, -7) : $url; + $decodedurl = html_entity_decode($url, ENT_QUOTES); - return $short_url; + $len = strlen($decodedurl); + $short_url = ($len > 40) ? substr($decodedurl, 0, 30) . "..." . substr($decodedurl, -7) : $decodedurl; + + return htmlentities($short_url, ENT_QUOTES); } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |