Skip to content

Commit

Permalink
HtmlModule: trims spaces around src and href (fixed)
Browse files Browse the repository at this point in the history
This reverts and fixes commit 9689aac
  • Loading branch information
dg committed Nov 3, 2015
1 parent 0f3cb9d commit 353dfdb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Texy/Modules/HtmlModule.php
Expand Up @@ -222,22 +222,26 @@ public function solveTag(Texy\HandlerInvocation $invocation, HtmlElement $el, $i
}
}

if ($name === 'img') {
if (isset($elAttrs['src'])) {
$elAttrs['src'] = trim($elAttrs['src']);
if (!$texy->checkURL($elAttrs['src'], $texy::FILTER_IMAGE)) {
return FALSE;
foreach (['src', 'href', 'name', 'id'] as $attr) {
if (isset($elAttrs[$attr])) {
$elAttrs[$attr] = is_string($elAttrs[$attr]) ? trim($elAttrs[$attr]) : '';
if ($elAttrs[$attr] === '') {
unset($elAttrs[$attr]);
}
}
}

$texy->summary['images'][] = $elAttrs['src'];
if ($name === 'img') {
if (!isset($elAttrs['src']) || !$texy->checkURL($elAttrs['src'], $texy::FILTER_IMAGE)) {
return FALSE;
}
$texy->summary['images'][] = $elAttrs['src'];

} elseif ($name === 'a') {
if (!isset($elAttrs['href']) && !isset($elAttrs['name']) && !isset($elAttrs['id'])) {
return FALSE;
}
if (isset($elAttrs['href'])) {
$elAttrs['href'] = trim($elAttrs['href']);
if ($texy->linkModule->forceNoFollow && strpos($elAttrs['href'], '//') !== FALSE) {
if (isset($elAttrs['rel'])) {
$elAttrs['rel'] = (array) $elAttrs['rel'];
Expand Down

0 comments on commit 353dfdb

Please sign in to comment.