Brave crash fix

8613c1e0f4
This commit is contained in:
FbIN Support 2025-09-05 14:47:12 +05:30
commit 6e59c0ffb9

View file

@ -240,13 +240,13 @@ class fuckhtml{
public function getElementsByFuzzyAttributeValue(string $name, string $value, $collection = null){ public function getElementsByFuzzyAttributeValue(string $name, string $value, $collection = null){
$elems = $this->getElementsByAttributeName($name, $collection); $elems = $this->getElementsByAttributeName($name, $collection);
$value = $value =
explode( explode(
" ", " ",
trim( trim(
preg_replace( preg_replace(
'/ \s+/', '/\s+/',
" ", " ",
$value $value
) )
@ -270,7 +270,7 @@ class fuckhtml{
) )
) )
); );
$ac = count($attrib_value); $ac = count($attrib_value);
$nc = count($value); $nc = count($value);
$cr = 0; $cr = 0;
@ -551,6 +551,33 @@ class fuckhtml{
switch($json[$i]){ switch($json[$i]){
case "\"":
case "'":
if(
$i > 2 ||
(
(
$json[$i - 1] === "\\" &&
$json[$i - 2] === "\\"
) ||
$json[$i - 1] !== "\\"
)
){
// found a non-escaped quote
if($in_quote === null){
// open quote
$in_quote = $json[$i];
}elseif($in_quote === $json[$i]){
// close quote
$in_quote = null;
}
}
break;
case "[": case "[":
if($in_quote === null){ if($in_quote === null){
@ -586,37 +613,20 @@ class fuckhtml{
$object_level--; $object_level--;
} }
break; break;
case "\"":
case "'":
if(
$i !== 0 &&
$json[$i - 1] !== "\\"
){
// found a non-escaped quote
if($in_quote === null){
// open quote
$in_quote = $json[$i];
}elseif($in_quote === $json[$i]){
// close quote
$in_quote = null;
}
}
break;
} }
if( if(
$start !== null &&
$array_level === 0 && $array_level === 0 &&
$object_level === 0 $object_level === 0 &&
$start !== null
){ ){
return substr($json, $start, $i - $start + 1); return substr($json, $start, $i - $start + 1);
break; break;
} }
} }
// fallback
return "[]";
} }
} }