yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.79k stars 467 forks source link

Invalid regular expression error in Safari #1226

Closed vpotter closed 3 years ago

vpotter commented 3 years ago

Version: 3.8.2 Error: SyntaxError: Invalid regular expression: invalid group specifier name

https://github.com/yourlabs/django-autocomplete-light/blob/29b91077a9935feb640d13b13f0fdf9d2fdbf2b3/src/dal/static/autocomplete_light/autocomplete_light.js#L128

The error is caused by a look-behind regex assertion which is not supported by Safari (according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#browser_compatibility)

The error is reproducible on both desktop & mobile.

jpic commented 3 years ago

Can someone find a regex that works with safari and suggest it here?

pySilver commented 3 years ago

@jpic Any development on this?

I've read the comment, but since I've never used django-nested-admin I'm not sure I get it right.

What type of id's you'd like to exclude among the following:

100-empty-200
x-empty-y
test100-empty-1test
foo-100-empty-200-bar

What if we simpy check it like this: https://regex101.com/r/R8FLpq/1 ?

Or 2 expressions one to check if there no match for <digits>-empty-<digits> AND there is match for -empty-

al-muammar commented 3 years ago

It breaks Safari for us as well :(

progl commented 3 years ago

found this https://stackoverflow.com/questions/51568821/works-in-chrome-but-breaks-in-safari-invalid-regular-expression-invalid-group/51568859

progl commented 3 years ago

but I reverting to 3.8.1 - it is good with safari

vtbassmatt commented 3 years ago

If I understand the comments right:

// return !this.id.match(/(?<!-\d+)-empty-(?!\d+-)/);
return !this.id.match(/-empty-/) || this.id.match(/-\d+-empty-\d+-/);
MathiasKowoll commented 3 years ago

I replaced the Ajax version from 3.8.1 to resolve the issue

MrAdam commented 3 years ago

Any chance that a new version will be released soon to PyPI with this fix included? At the moment DAL is non-functional in Safari browsers (both desktop and mobile) for me.

jpic commented 3 years ago

Sure, anyone can confirm the current master is working in production for them?

philgyford commented 3 years ago

It works for me!

(Safari 14.1 on macOS, and whatever the latest Safari is on iOS)

jpic commented 3 years ago

Thank you for your response!

Released 3.9.0rc1

On Sun, May 16, 2021 at 6:18 PM Phil Gyford @.***> wrote:

It works for me!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/yourlabs/django-autocomplete-light/issues/1226#issuecomment-841839277, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXDLAAVWD3PWL3TSRNPRLTN7V4VANCNFSM4Y56SVDQ .

-- ∞