summaryrefslogtreecommitdiff
path: root/lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-06-05 21:52:37 +0400
committerAndrew Dolgov <[email protected]>2012-06-05 21:52:37 +0400
commitcb73535c8eae02092df984bafbecabbce8049cd0 (patch)
tree2a9a68d5c636381a7617fb0dc50a66f87758e9e9 /lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI
parent010efc9b814b433bc60353caec185d905688a32b (diff)
Revert "Update HTML Purifier to version 4.4.0."
This reverts commit dd205fbad642ace6d0e33c8553f7d73404f140b4.
Diffstat (limited to 'lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI')
-rw-r--r--lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php45
1 files changed, 6 insertions, 39 deletions
diff --git a/lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php b/lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
index 125decb2d..feca469d7 100644
--- a/lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
+++ b/lib/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
@@ -44,8 +44,9 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
// A regular domain name.
- // This doesn't match I18N domain names, but we don't have proper IRI support,
- // so force users to insert Punycode.
+ // This breaks I18N domain names, but we don't have proper IRI support,
+ // so force users to insert Punycode. If there's complaining we'll
+ // try to fix things into an international friendly form.
// The productions describing this are:
$a = '[a-z]'; // alpha
@@ -56,44 +57,10 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
// toplabel = alpha | alpha *( alphanum | "-" ) alphanum
$toplabel = "$a($and*$an)?";
// hostname = *( domainlabel "." ) toplabel [ "." ]
- if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) {
- return $string;
- }
-
- // If we have Net_IDNA2 support, we can support IRIs by
- // punycoding them. (This is the most portable thing to do,
- // since otherwise we have to assume browsers support
-
- if ($config->get('Core.EnableIDNA')) {
- $idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => false, 'strict' => true));
- // we need to encode each period separately
- $parts = explode('.', $string);
- try {
- $new_parts = array();
- foreach ($parts as $part) {
- $encodable = false;
- for ($i = 0, $c = strlen($part); $i < $c; $i++) {
- if (ord($part[$i]) > 0x7a) {
- $encodable = true;
- break;
- }
- }
- if (!$encodable) {
- $new_parts[] = $part;
- } else {
- $new_parts[] = $idna->encode($part);
- }
- }
- $string = implode('.', $new_parts);
- if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) {
- return $string;
- }
- } catch (Exception $e) {
- // XXX error reporting
- }
- }
+ $match = preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string);
+ if (!$match) return false;
- return false;
+ return $string;
}
}