-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
Incorrect parsing of nested params with closing square bracket ] in property name #493
Comments
I recently came across this weird query string combination. Since I also (attempt to) maintain a Python and a Dart port of this awesome library I attempted to fix it in Python and Dart respectively. The Python fix techouse/qs_codec#1 involved addressing the regular expression brackets: re.Pattern[str] = re.compile(r"(\[[^[\]]*])") which matches a left bracket To match the outermost brackets, including nested brackets, we must use a recursive regular expression. However, Python's from regex import regex
brackets: regex.Pattern[str] = regex.compile(r"\[(?:[^\[\]]|(?R))*\]") This regular expression matches a left bracket In the Dart fix techouse/qs#13 I used recursive_regex to achieve the same and get from final RegExp brackets = RegExp(r'(\[[^[\]]*])'); to import 'package:recursive_regex/recursive_regex.dart';
final RegExp brackets = RecursiveRegex(startDelimiter: '[', endDelimiter: ']'); I'm not sure how best to implement this fix here, since JavaScript does not provide the PCRE recursive parameter Don't we all just love regular expressions 🙈 To be honest, this issue is quite fringe and a heavy dependency could be a dealbreaker for more people than are willing to accept the lack of this fix. In my opinion, it's ultimately down to @ljharb to give the go-ahead on this or not. Thoughts? CC / @gronke |
It should definitely be fixed, but I’m not excited about relying on regular expressions for a non-regular DSL :-) |
Search parameters with closing square bracket in nested property names are parsed incorrectly.
Here demonstrated with
/?search[withbracket[]]=foobar
:For comparison the result with the native URL object:
When parsing a query without braces, the result looks like:
So it should be a nested object.
Current Result
Expected Result
The text was updated successfully, but these errors were encountered: