[geeklog-hg] geeklog: Removed hardcoded checks for TLD in domain names (bugs ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Jun 11 02:37:26 EDT 2015
changeset 9606:5c6abdcb544a
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/5c6abdcb544a
user: Kenji ITO <mystralkk at gmail.com>
date: Thu Jun 11 15:36:41 2015 +0900
description:
Removed hardcoded checks for TLD in domain names (bugs #0001149, #0001802)
diffstat:
public_html/lib-common.php | 21 +++++++++++++--------
system/classes/validator.class.php | 2 +-
2 files changed, 14 insertions(+), 9 deletions(-)
diffs (73 lines):
diff -r a764295893ed -r 5c6abdcb544a public_html/lib-common.php
--- a/public_html/lib-common.php Mon Jun 08 15:57:35 2015 -0400
+++ b/public_html/lib-common.php Thu Jun 11 15:36:41 2015 +0900
@@ -6977,8 +6977,7 @@
* @return string the same string, with links enclosed in <a>...</a> tags
*
*/
-function COM_makeClickableLinks( $text )
-{
+function COM_makeClickableLinks($text) {
global $_CONF;
if (! $_CONF['clickable_links']) {
@@ -6988,7 +6987,7 @@
// These regular expressions will work for this purpuse, but
// they should NOT be used for validating links.
- // matches anything starting with http:// or https:// or ftp:// or ftps://
+ // Matches anything starting with http:// or https:// or ftp:// or ftps://
$regex = '/(?<=^|[\n\r\t\s\(\)\[\]<>";])((?:(?:ht|f)tps?:\/{2})(?:[^\n\r\t\s\(\)\[\]<>"&]+(?:&)?)+)(?=[\n\r\t\s\(\)\[\]<>"&]|$)/i';
$replace = create_function(
'$match',
@@ -6997,9 +6996,9 @@
$text = preg_replace_callback($regex, $replace, $text);
- // matches anything containing a top level domain: xxx.com or xxx.yyy.net/stuff.php or xxx.yyy.zz
+ // Matches anything containing a top level domain: xxx.com or xxx.yyy.net/stuff.php or xxx.yyy.zz
// list taken from: http://en.wikipedia.org/wiki/List_of_Internet_TLDs
- $regex = '/(?<=^|[\n\r\t\s\(\)\[\]<>";])((?:[a-z0-9]+\.)*[a-z0-9]+\.(?:aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|post|pro|tel|travel|[a-z]{2})(?:[\/?#](?:[^\n\r\t\s\(\)\[\]<>"&]+(?:&)?)*)?)(?=[\n\r\t\s\(\)\[\]<>"&]|$)/i';
+ $regex = '/(?<=^|[\n\r\t\s\(\)\[\]<>";])((?:[a-z0-9]+\.)*[a-z0-9-]+\.(?:[a-z]{2,}|xn--[0-9a-z]+)(?:[\/?#](?:[^\n\r\t\s\(\)\[\]<>"&]+(?:&)?)*)?)(?=[\n\r\t\s\(\)\[\]<>"&]|$)/i';
$replace = create_function(
'$match',
'return COM_makeClickableLinksCallback(\'http://\', $match[1]);'
@@ -7018,9 +7017,13 @@
* @return string link enclosed in <a>...</a> tags
*
*/
-function COM_makeClickableLinksCallback( $http, $link )
-{
+function COM_makeClickableLinksCallback($http, $link) {
global $_CONF;
+ static $encoding = null;
+
+ if ($encoding === null) {
+ $encoding = COM_getEncodingt();
+ }
// When $link ends with a period, the period will be moved out of the link
// text (bug #0001675)
@@ -7037,7 +7040,9 @@
$text = $link;
}
- return "<a href=\"{$http}{$link}\">{$text}</a>{$end}";
+ $text = htmlspecialchars($text, ENT_QUOTES, $encoding);
+
+ return '<a href="' . $http . $link . '">' . $text . '</a>' . $end;
}
/**
diff -r a764295893ed -r 5c6abdcb544a system/classes/validator.class.php
--- a/system/classes/validator.class.php Mon Jun 08 15:57:35 2015 -0400
+++ b/system/classes/validator.class.php Thu Jun 11 15:36:41 2015 +0900
@@ -67,7 +67,7 @@
* @access private
*/
var $__pattern = array(
- 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
+ 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,}|xn--[0-9a-z]+)'
);
/**
More information about the geeklog-cvs
mailing list