Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preg_match(): Compilation failed: invalid range in character class at offset #87

Open
sami-42 opened this issue Mar 31, 2022 · 6 comments

Comments

@sami-42
Copy link

sami-42 commented Mar 31, 2022

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?

@nitadan18
Copy link

nitadan18 commented Apr 14, 2022

  • \simple_html_dom.php on line 1378 from "/^[\w-:]+$/" to "/^[\w\-:]+$/";
  • \simple_html_dom.php on line 679 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)

@patrickkasie
Copy link

patrickkasie commented Apr 26, 2022

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

@nitadan18
Copy link

maybe, i not sure, try to fork repository (how to - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer).

@arcanisgk
Copy link

any update???

@patrickkasie
Copy link

Doesn't look like it. Just keep using the solution provided by nitadan18, or use the fix provided by rdmpage (Click the mention)

@anayarojo
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants