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

error: look-behind requires fixed-width pattern #5970

Closed
gailmargolis76 opened this issue Jun 6, 2019 · 9 comments
Closed

error: look-behind requires fixed-width pattern #5970

gailmargolis76 opened this issue Jun 6, 2019 · 9 comments

Comments

@gailmargolis76
Copy link

I keep getting this error when i try to use this library. I installed python3-dev, python3-pip and regex but that doesn't seem to fix it! Any ideas what's wrong?

@gailmargolis76
Copy link
Author

Just wanted to add that I'm using the Python version

@Findus23
Copy link
Member

Findus23 commented Jun 6, 2019

Hi,
I'd recommend you to report this to the developer of the python port:
https://github.com/thinkwelltwd/device_detector

But I am getting the same error on install, so maybe either some new in python invalid regex were added in the last versions or it maybe has issues with python3.

@Findus23
Copy link
Member

Findus23 commented Jun 6, 2019

You need to install python3-regex to fix the issue. (or run pip install regex depending on how you manage your dependencies)
With thinkwelltwd/device_detector#18 this shouldn't be needed anymore.

@sgiehl
Copy link
Member

sgiehl commented Jun 7, 2019

thanks @Findus23 for looking into it. I'll close the issue for now.

@gailmargolis76
Copy link
Author

i tried pip install regex, it still didn't work! For context, I'm on a Mac OS X

@spiderpug
Copy link
Contributor

Hi @sgiehl ,

we are maintaining a ruby version of the device detector at https://github.com/podigee/device_detector and noticed that one regular expression is not available in Ruby: there is no support for non-fixed-width look-behinds, see https://github.com/kkos/oniguruma/blob/master/doc/RE#L283-L290 for details.

For now we got rid of this violation and removed some test ( podigee/device_detector@e87bad0 ). Do you see a way to rewrite this Regex?

@sgiehl
Copy link
Member

sgiehl commented Aug 5, 2019

But https://github.com/kkos/oniguruma/blob/master/doc/RE#L283-L290 says

          Subexp of look-behind must be fixed-width.
          But top-level alternatives can be of various lengths.
          ex. (?<=a|bc) is OK. (?<=aaa(?:b|cd)) is not allowed.

So i don't understand why
(?<!ZTE BLADE |ImSmart |ERGO |X-Style Tab )a(?:101|110|2[10]0|211|50[10]|51[10]|70[10])[);/ ]
shouldn't be valid. Or doesn't that apply for negativ look-behinds?

@spiderpug
Copy link
Contributor

Thanks for the response. I apologise for the trouble but I was mislead by the error message. The regex is actually not the problem.

This seems to be a bug in ruby https://bugs.ruby-lang.org/issues/13671 / or library Onigmo, see k-takata/Onigmo#92 .

It occurs in combination with /.../i (ignore case) and if the user agent contains non-latin characters, like specified in the tests, e.g.:

Versão/4.0
eZee’Tab
Build/Xperia Ultimate HDâ„¢ 3.0.2
Ramos X10 PRO时尚版

I think there is nothing to be done on your side. 👍

@sgiehl
Copy link
Member

sgiehl commented Aug 6, 2019

ok. Thanks for the feedback. Let me know if anything else needs to be adjusted...

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

No branches or pull requests

4 participants