aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2025-09-05 01:59:01 -0400
committerlolcat <will@lolcat.ca>2025-09-05 01:59:01 -0400
commit8613c1e0f49f44e54d0057b379cef127d32c3e1d (patch)
treeb1104d101b6af1e0929c7017933767a25325a941
parentd4aaebcd802087205ce4f91387c7ccab2fa49b7a (diff)
brave crash fix
-rw-r--r--lib/fuckhtml.php54
1 files changed, 32 insertions, 22 deletions
diff --git a/lib/fuckhtml.php b/lib/fuckhtml.php
index 3ea256f..08ca8e3 100644
--- a/lib/fuckhtml.php
+++ b/lib/fuckhtml.php
@@ -551,6 +551,33 @@ class fuckhtml{
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 "[":
if($in_quote === null){
@@ -586,37 +613,20 @@ class fuckhtml{
$object_level--;
}
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(
- $start !== null &&
$array_level === 0 &&
- $object_level === 0
+ $object_level === 0 &&
+ $start !== null
){
return substr($json, $start, $i - $start + 1);
break;
}
}
+
+ // fallback
+ return "[]";
}
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage