php-simple-html-dom-parser
php-simple-html-dom-parser copied to clipboard
preg_match(): Compilation failed: invalid range in character class at offset
preg_match(): Compilation failed: invalid range in character class at offset 4 in \simple_html_dom.php on line 1378
Hey anybody knows why this problem occured? Can anybody give the fix to this bug?
-
\simple_html_dom.php
on line1378
from"/^[\w-:]+$/"
to"/^[\w\-:]+$/"
; -
\simple_html_dom.php
on line679
from$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
to$pattern = "/([\w\-:\*]*)(?:\#([\w\-]+)|\.([\w\-]+))?(?:\[@?(!?[\w\-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
this is from php 7.3 update from PCRE to PCRE2 (https://php.watch/versions/7.3/pcre2
)
When I tried updating this application, it keeps on getting the incorrect lines for one specific website, even upon deletion of the full application and reacquiring it with another "composer update" in the root folder of the website. However, for other specific websites, it has the corrected lines above. It obtains version 1.5.2 on both ocassions. I have absolutely no idea why this isn't obtained correctly on some websites whereas it is on others, does anyone know why?
Edit: It happens because some websites are installed differently. Or rather, its CMS. When installing through composer, the CMS has no control over the applications provided by all dependencies, but it can do adjustments within its own core, which means it can correctly update the code in when unpacking its zip. This information for me doesn't help me much, other than re-assuring me a future update of the CMS shouldn't overwrite the corrections suggested by creative3x
maybe, i not sure, try to fork repository (how to - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer
).
any update???
Doesn't look like it. Just keep using the solution provided by nitadan18, or use the fix provided by rdmpage (Click the mention)
I've used this alternative in PHP 8.2, installing:
composer require paquettg/php-html-parser
Using:
use PHPHtmlParser\Dom;
$dom = new Dom;
$dom->loadFromFile('tests/data/big.html');
Or
use PHPHtmlParser\Dom;
$dom = new Dom;
$dom->loadStr('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
More details: https://packagist.org/packages/paquettg/php-html-parser