aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef')
-rw-r--r--vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php14
-rw-r--r--vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php46
-rw-r--r--vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php18
3 files changed, 61 insertions, 17 deletions
diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php
index ad2cb90ad..af6b8a05d 100644
--- a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php
+++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php
@@ -27,6 +27,13 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
$definition = $config->getCSSDefinition();
$allow_duplicates = $config->get("CSS.AllowDuplicates");
+ $universal_attrdef = new HTMLPurifier_AttrDef_Enum(
+ array(
+ 'initial',
+ 'inherit',
+ 'unset',
+ )
+ );
// According to the CSS2.1 spec, the places where a
// non-delimiting semicolon can appear are in strings
@@ -96,16 +103,13 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
if (!$ok) {
continue;
}
- // inefficient call, since the validator will do this again
- if (strtolower(trim($value)) !== 'inherit') {
- // inherit works for everything (but only on the base property)
+ $result = $universal_attrdef->validate($value, $config, $context);
+ if ($result === false) {
$result = $definition->info[$property]->validate(
$value,
$config,
$context
);
- } else {
- $result = 'inherit';
}
if ($result === false) {
continue;
diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php
new file mode 100644
index 000000000..e08e2c496
--- /dev/null
+++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * Validates a ratio as defined by the CSS spec.
+ */
+class HTMLPurifier_AttrDef_CSS_Ratio extends HTMLPurifier_AttrDef
+{
+ /**
+ * @param string $ratio Ratio to validate
+ * @param HTMLPurifier_Config $config Configuration options
+ * @param HTMLPurifier_Context $context Context
+ *
+ * @return string|boolean
+ *
+ * @warning Some contexts do not pass $config, $context. These
+ * variables should not be used without checking HTMLPurifier_Length
+ */
+ public function validate($ratio, $config, $context)
+ {
+ $ratio = $this->parseCDATA($ratio);
+
+ $parts = explode('/', $ratio, 2);
+ $length = count($parts);
+
+ if ($length < 1 || $length > 2) {
+ return false;
+ }
+
+ $num = new \HTMLPurifier_AttrDef_CSS_Number();
+
+ if ($length === 1) {
+ return $num->validate($parts[0], $config, $context);
+ }
+
+ $num1 = $num->validate($parts[0], $config, $context);
+ $num2 = $num->validate($parts[1], $config, $context);
+
+ if ($num1 === false || $num2 === false) {
+ return false;
+ }
+
+ return $num1 . '/' . $num2;
+ }
+}
+
+// vim: et sw=4 sts=4
diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
index ddc5dfbea..17a97c1ec 100644
--- a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
+++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php
@@ -63,24 +63,18 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
// This doesn't match I18N domain names, but we don't have proper IRI support,
// so force users to insert Punycode.
- // There is not a good sense in which underscores should be
- // allowed, since it's technically not! (And if you go as
- // far to allow everything as specified by the DNS spec...
- // well, that's literally everything, modulo some space limits
- // for the components and the overall name (which, by the way,
- // we are NOT checking!). So we (arbitrarily) decide this:
- // let's allow underscores wherever we would have allowed
- // hyphens, if they are enabled. This is a pretty good match
- // for browser behavior, for example, a large number of browsers
- // cannot handle foo_.example.com, but foo_bar.example.com is
- // fairly well supported.
+ // Underscores defined as Unreserved Characters in RFC 3986 are
+ // allowed in a URI. There are cases where we want to consider a
+ // URI containing "_" such as "_dmarc.example.com".
+ // Underscores are not allowed in the default. If you want to
+ // allow it, set Core.AllowHostnameUnderscore to true.
$underscore = $config->get('Core.AllowHostnameUnderscore') ? '_' : '';
// Based off of RFC 1738, but amended so that
// as per RFC 3696, the top label need only not be all numeric.
// The productions describing this are:
$a = '[a-z]'; // alpha
- $an = '[a-z0-9]'; // alphanum
+ $an = "[a-z0-9$underscore]"; // alphanum
$and = "[a-z0-9-$underscore]"; // alphanum | "-"
// domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
$domainlabel = "$an(?:$and*$an)?";