Skip to content

Commit e583127

Browse files
authored
Merge pull request #43 from Crizz0/issue/41
Allow br and hr without closing />
2 parents 023f992 + 632e398 commit e583127

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Phpbb/TranslationValidator/Validator/LangKeyValidator.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,13 @@ public function validateHtml($file, $key, $sourceString, $originString)
675675
$ignoreAdditional = true;
676676
}
677677

678+
// missing closingTag allowed in: <br>, <hr>, <img>
679+
$allowedMissingClosingTag = array(
680+
'br',
681+
'hr',
682+
'img',
683+
);
684+
678685
$tag = (strpos($possibleHtml, ' ') !== false) ? substr($possibleHtml, 1, strpos($possibleHtml, ' ') - 1) : substr($possibleHtml, 1, strpos($possibleHtml, '>') - 1);
679686
$tag = ($openingTag) ? $tag : substr($tag, 1);
680687

@@ -688,7 +695,7 @@ public function validateHtml($file, $key, $sourceString, $originString)
688695
}
689696
$failedUnclosed = true;
690697
}
691-
else if (substr($possibleHtml, -3) !== ' />')
698+
else if (substr($possibleHtml, -3) !== ' />' && !in_array($tag, $allowedMissingClosingTag))
692699
{
693700
$openTags[] = $tag;
694701
}
@@ -767,6 +774,8 @@ public function validateHtml($file, $key, $sourceString, $originString)
767774
* - <samp>
768775
* - <u>
769776
* - <br />
777+
* - <br>
778+
* - <hr>
770779
* Fatal:
771780
* - others
772781
*
@@ -786,6 +795,8 @@ protected function getErrorLevelForAdditionalHtml($html)
786795
'<samp>',
787796
'<u>',
788797
'<br />',
798+
'<br>',
799+
'<hr>'
789800
)))
790801
{
791802
return Output::NOTICE;

0 commit comments

Comments
 (0)