Use a constant for HTML tags regex
This commit is contained in:
parent
00c62bf150
commit
df761ceef7
@ -44,6 +44,7 @@ class Odf
|
|||||||
public $userdefined=array();
|
public $userdefined=array();
|
||||||
|
|
||||||
const PIXEL_TO_CM = 0.026458333;
|
const PIXEL_TO_CM = 0.026458333;
|
||||||
|
const FIND_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
||||||
const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
||||||
|
|
||||||
|
|
||||||
@ -329,7 +330,7 @@ class Odf
|
|||||||
*/
|
*/
|
||||||
private function _isHtmlTag($text)
|
private function _isHtmlTag($text)
|
||||||
{
|
{
|
||||||
return preg_match('/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/', $text);
|
return preg_match(self::FIND_TAGS_REGEX, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,7 +340,7 @@ class Odf
|
|||||||
*/
|
*/
|
||||||
private function _hasHtmlTag($text)
|
private function _hasHtmlTag($text)
|
||||||
{
|
{
|
||||||
$result = preg_match_all('/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/', $text);
|
$result = preg_match_all(self::FIND_TAGS_REGEX, $text);
|
||||||
return is_numeric($result) && $result > 0;
|
return is_numeric($result) && $result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +356,7 @@ class Odf
|
|||||||
|
|
||||||
while (strlen($tempHtml) > 0) {
|
while (strlen($tempHtml) > 0) {
|
||||||
// Check if the string includes a html tag
|
// Check if the string includes a html tag
|
||||||
if (preg_match_all('/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/', $tempHtml, $matches)) {
|
if (preg_match_all(self::FIND_TAGS_REGEX, $tempHtml, $matches)) {
|
||||||
$tagOffset = strpos($tempHtml, $matches[0][0]);
|
$tagOffset = strpos($tempHtml, $matches[0][0]);
|
||||||
// Check if the string starts with the html tag
|
// Check if the string starts with the html tag
|
||||||
if ($tagOffset > 0) {
|
if ($tagOffset > 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user