Add title and alt attributes for img tags (useful for xkcd fans)
This commit is contained in:
parent
8550fea8c1
commit
9da824c361
18
vendor/PicoFeed/Filter.php
vendored
18
vendor/PicoFeed/Filter.php
vendored
@ -43,7 +43,7 @@ class Filter
|
|||||||
'br' => array(),
|
'br' => array(),
|
||||||
'del' => array(),
|
'del' => array(),
|
||||||
'a' => array('href'),
|
'a' => array('href'),
|
||||||
'img' => array('src'),
|
'img' => array('src', 'title', 'alt'),
|
||||||
'figure' => array(),
|
'figure' => array(),
|
||||||
'figcaption' => array(),
|
'figcaption' => array(),
|
||||||
'cite' => array(),
|
'cite' => array(),
|
||||||
@ -219,13 +219,13 @@ class Filter
|
|||||||
|
|
||||||
if ($this->isAllowedIframeResource($value)) {
|
if ($this->isAllowedIframeResource($value)) {
|
||||||
|
|
||||||
$attr_data .= ' '.$attribute.'="'.$value.'"';
|
$attr_data .= ' '.$attribute.'="'.$this->escape($value).'"';
|
||||||
$used_attributes[] = $attribute;
|
$used_attributes[] = $attribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($this->isRelativePath($value)) {
|
else if ($this->isRelativePath($value)) {
|
||||||
|
|
||||||
$attr_data .= ' '.$attribute.'="'.$this->getAbsoluteUrl($value, $this->url).'"';
|
$attr_data .= ' '.$attribute.'="'.$this->escape($this->getAbsoluteUrl($value, $this->url)).'"';
|
||||||
$used_attributes[] = $attribute;
|
$used_attributes[] = $attribute;
|
||||||
}
|
}
|
||||||
else if ($this->isAllowedProtocol($value) && ! $this->isBlacklistedMedia($value)) {
|
else if ($this->isAllowedProtocol($value) && ! $this->isBlacklistedMedia($value)) {
|
||||||
@ -241,13 +241,13 @@ class Filter
|
|||||||
// Replace protocol-relative url // by http://
|
// Replace protocol-relative url // by http://
|
||||||
if (substr($value, 0, 2) === '//') $value = 'http:'.$value;
|
if (substr($value, 0, 2) === '//') $value = 'http:'.$value;
|
||||||
|
|
||||||
$attr_data .= ' '.$attribute.'="'.$value.'"';
|
$attr_data .= ' '.$attribute.'="'.$this->escape($value).'"';
|
||||||
$used_attributes[] = $attribute;
|
$used_attributes[] = $attribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($this->validateAttributeValue($attribute, $value)) {
|
else if ($this->validateAttributeValue($attribute, $value)) {
|
||||||
|
|
||||||
$attr_data .= ' '.$attribute.'="'.$value.'"';
|
$attr_data .= ' '.$attribute.'="'.$this->escape($value).'"';
|
||||||
$used_attributes[] = $attribute;
|
$used_attributes[] = $attribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,11 +310,17 @@ class Filter
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (! $this->strip_content) {
|
if (! $this->strip_content) {
|
||||||
$this->data .= htmlspecialchars($content, ENT_QUOTES, 'UTF-8', false);
|
$this->data .= $this->escape($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function escape($content)
|
||||||
|
{
|
||||||
|
return htmlspecialchars($content, ENT_QUOTES, 'UTF-8', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getAbsoluteUrl($path, $url)
|
public static function getAbsoluteUrl($path, $url)
|
||||||
{
|
{
|
||||||
$components = parse_url($url);
|
$components = parse_url($url);
|
||||||
|
Loading…
Reference in New Issue
Block a user