-
-
Notifications
You must be signed in to change notification settings - Fork 7
Username portion causes failure if > 16 characters #4
Comments
My colleague @aripringle was doing some additional testing on this and he discovered that the preg_match call that the URL validator is doing is actually returning
He was able to make the URL pass validation if he bumped the backtrack limit as high as 5,000,000:
|
This is the result of the current In other words, username and password should be removed in favor of user info and the group should be:
This avoids the backtracking issue and complies better with the actual RFC. If you want to keep support for direct splitting, do the following:
|
I tried both of those approaches and still encounter the backtrack limit error (at the default limit of 1,000,000). |
I will investigate further but I'm on vacation right now and will be back home next week. I'll get back to you then. |
No worries, enjoy your vacation! I've been messing with it a little bit, no progress yet though. |
An atomic group should solve it:
I have a very tight schedule these days and not much time. You might want to consider using another, better maintained package instead (e.g. |
Unfortunately that change doesn't seem to affect the backtracking behavior, I still get the backtrack limit exceeded error on this url: I can certainly look at the League URI package. I'm curious how it performs against the URLs in your test suite. |
Making sure that the atomic group only matches once will help:
I will overhaul the library a bit and release a new version soon. |
Ah, nice! That fixes it. It doesn't seem necessary for the tests to pass, but would it affect performance/efficiency at all to exclude a colon from the username portion as well?:
|
The RegEx is not very performant nor efficient and the library should not distinguish between username and password but treat it all simply as user info (RFC 3986). This is what I have now for the next major of this lib:
It's not fully tested yet but much closer to RFC 3986 and really fast. It parser your |
I've looked over the regex and can't seem to figure out why this would happen.
We had a case where php-url-validator was rejecting a URL because the username was too long.
For example, if I put this URL in the test suite, it fails:
However, if I reduce the username by 1 character, it passes:
Any idea why this might be happening? (Notice that the password field can be any length, i.e., this still fails)
but this passes:
I tried changing the named parameter in the regex to something other than "username", just in case, but it still fails if over 16 characters.
The text was updated successfully, but these errors were encountered: