diff options
| author | lolcat <will@lolcat.ca> | 2026-05-05 03:32:45 -0400 |
|---|---|---|
| committer | lolcat <will@lolcat.ca> | 2026-05-05 03:32:45 -0400 |
| commit | 6086c63148f7f859da29280377861166a7eab387 (patch) | |
| tree | 4a5dc81112df23a1a044c9a2e5cd714f80dbb762 | |
| parent | d2b0a414ad5a7639bd107ea273dd1a27fc296811 (diff) | |
extract_json fix
| -rw-r--r-- | lib/fuckhtml.php | 29 | ||||
| -rw-r--r-- | scraper/brave.php | 5 |
2 files changed, 12 insertions, 22 deletions
diff --git a/lib/fuckhtml.php b/lib/fuckhtml.php index 9018627..143d113 100644 --- a/lib/fuckhtml.php +++ b/lib/fuckhtml.php @@ -553,28 +553,21 @@ class fuckhtml{ case "\"": case "'": - if( - $i !== 0 && // only check if a quote could be there - ( - ( - $json[$i - 1] === "\\" && - ( - $i === 2 || - $json[$i - 2] === "\\" - ) - ) || - $json[$i - 1] !== "\\" - ) - ){ - // found a non-escaped quote - + // count preceding backslashes + $bsCount = 0; + $j = $i - 1; + + while($j >= 0 && $json[$j] === "\\"){ + $bsCount++; + $j--; + } + + // quote is NOT escaped if even number of backslashes + if($bsCount % 2 === 0){ if($in_quote === null){ - // open quote $in_quote = $json[$i]; - }elseif($in_quote === $json[$i]){ - // close quote $in_quote = null; } diff --git a/scraper/brave.php b/scraper/brave.php index ed29158..91b081d 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -347,11 +347,8 @@ class brave{ $q["spellcheck"] = "0"; } } - /* - $handle = fopen("scraper/brave.html", "r"); - $html = fread($handle, filesize("scraper/brave.html")); - fclose($handle);*/ + //$html = file_get_contents("scraper/brave.html"); try{ $html = $this->get( |
