Web-Facing Change PSA: URLPattern: RegExp v flag instead of u

504 views
Skip to first unread message

Shunya Shishido

unread,
Nov 15, 2023, 3:16:36 AM11/15/23
to blink-dev

Contact emails

sisid...@chromium.org

Specification

https://urlpattern.spec.whatwg.org

Summary

The URL Pattern API allows developers to specify pattern strings. Those are transformed to regular expressions internally. When the API was first implemented, these regular expressions were compiled with the u flag. We're going to update it to the v flag, enabling Unicode sets.



Blink component

Blink>URLPattern

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

https://github.com/tc39/proposal-regexp-v-flag#how-is-the-v-flag-different-from-the-u-flag This doc has a list the potentially breaking changes between u and v. Some patterns that previously would compile, now throw an error with the v flag, specifically those with a character class including either an unescaped special character or a double punctuator. I believe it does not significantly affect the patterns in use today. From UMA metric on Beta, incompatible patterns are less than 0.001% of the total compilation. Also, the use counter of the API itself has only 0.11%. The expected impact is extremely limited.



Gecko: No signal

WebKit: No signal

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

No

Is this feature fully tested by web-platform-tests?

Yes

https://wpt.fyi/results/urlpattern/urlpattern.any.html Tests for set notations were added in https://github.com/web-platform-tests/wpt/pull/43014



Flag name on chrome://flags



Finch feature name

URLPatternRegexpUnicodeSetsMode

Requires code in //chrome?

False

Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=1482263

Estimated milestones

Shipping on desktop121
Shipping on Android121


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

None

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5122651463090176

This intent message was generated by Chrome Platform Status.

Kenneth Rohde Christiansen

unread,
Nov 15, 2023, 3:34:11 AM11/15/23
to Shunya Shishido, blink-dev
I assume this means that polyfill needs to be updated as well. Can you file an issue on GitHub: https://github.com/kenchris/urlpattern-polyfill 

Cheers,
Kenneth

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAGMyg-ZAnsDEw1haRd1HOuYcieHOYKZ73oYAQ3SfWv9umsd-TA%40mail.gmail.com.


--
Kenneth Rohde Christiansen
Web Platform Architect, Intel Corporation.
Phone  +45 4294 9458 ﹆﹆﹆

Shunya Shishido

unread,
Nov 15, 2023, 3:49:49 AM11/15/23
to Kenneth Rohde Christiansen, blink-dev
Filed an issue, I'm happy to work on it.

Thank you for the heads up!

Rupert Wiser

unread,
Nov 15, 2023, 4:57:08 AM11/15/23
to blink-dev, Shunya Shishido, blink-dev, kenneth.ch...@gmail.com
"Will this feature be supported on all six Blink platforms" I see the answer is no. Which platforms are not going to be supported? 

On Wednesday, November 15, 2023 at 8:49:49 AM UTC Shunya Shishido wrote:
Filed an issue, I'm happy to work on it.

Thank you for the heads up!

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

Mike Taylor

unread,
Nov 15, 2023, 11:04:21 AM11/15/23
to Shunya Shishido, blink-dev

This feels like something that has the potential to be rather thorny... I would expect 0.001% on Beta to be higher on Stable.

Given that your UMA landed in M120, could we wait a few weeks to look at the stable data, then come back with an Intent to Ship? This seems slightly riskier for a page than https://groups.google.com/a/chromium.org/g/blink-dev/c/gIyvMw0n2qw/m/-WZC9C4VCQAJ (which had server-side validation as a fallback).

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Jeremy Roman

unread,
Nov 15, 2023, 12:44:57 PM11/15/23
to Mike Taylor, Shunya Shishido, blink-dev
The "less than 0.001%" number is not a fraction of page loads, but of URL patterns created -- so it's a minuscule fraction of pages that are using URLPattern at all (which itself is 0.11%); if you look up Blink.URLPattern.IncompatiblePatternWithUnicodeSetsMode in UMA you'll see the raw data, but it truly is essentially zero samples.

Most of the characters that would be invalid without escaping aren't as common in URLs without percent encoding, the major exception being -, because something like /[-a-z]/u works but /[-a-z]/v doesn't and the author must write /[\-a-z]/v.

(I'll leave it to Shunya to comment on the pros/cons of waiting for stable data.)

Shunya Shishido

unread,
Nov 15, 2023, 11:55:43 PM11/15/23
to Jeremy Roman, Mike Taylor, blink-dev
We can wait for more data from the upcoming M120 stable for more confidence, but in that case we need an Intent to Ship instead of this PSA?
As Jeremy mentioned the actual usage is nearly zero, so I believe this change very unlikely breaks sites.

"Will this feature be supported on all six Blink platforms" I see the answer is no. Which platforms are not going to be supported? 
Let me correct, the answer is yes. I also updated the chromestatus entry.

Mathias Bynens

unread,
Nov 16, 2023, 1:26:25 AM11/16/23
to Shunya Shishido, Jeremy Roman, Mike Taylor, blink-dev
In case helpful: the earlier i2s for html-pattern-v has some compat data on the specific case of upgrading the HTML `pattern` attribute from the `u` to the `v` flag: https://groups.google.com/a/chromium.org/g/blink-dev/c/gIyvMw0n2qw/m/3XaP6hFpAgAJ

Jeremy Roman

unread,
Nov 16, 2023, 11:22:49 AM11/16/23
to Mathias Bynens, Shunya Shishido, Mike Taylor, blink-dev
On Thu, Nov 16, 2023 at 1:26 AM Mathias Bynens <mat...@chromium.org> wrote:
In case helpful: the earlier i2s for html-pattern-v has some compat data on the specific case of upgrading the HTML `pattern` attribute from the `u` to the `v` flag: https://groups.google.com/a/chromium.org/g/blink-dev/c/gIyvMw0n2qw/m/3XaP6hFpAgAJ

On Thu, Nov 16, 2023 at 5:55 AM Shunya Shishido <sisid...@chromium.org> wrote:
We can wait for more data from the upcoming M120 stable for more confidence, but in that case we need an Intent to Ship instead of this PSA?
As Jeremy mentioned the actual usage is nearly zero, so I believe this change very unlikely breaks sites.

Also worth noting this feature is Finchable, so in the unlikely event we see a spike in this in stable, we can Finch it off to reconsider before enabling this by default hits the stable channel.

Mike Taylor

unread,
Nov 16, 2023, 1:10:56 PM11/16/23
to Jeremy Roman, Mathias Bynens, Shunya Shishido, blink-dev

On 11/16/23 11:22 AM, Jeremy Roman wrote:

On Thu, Nov 16, 2023 at 1:26 AM Mathias Bynens <mat...@chromium.org> wrote:
In case helpful: the earlier i2s for html-pattern-v has some compat data on the specific case of upgrading the HTML `pattern` attribute from the `u` to the `v` flag: https://groups.google.com/a/chromium.org/g/blink-dev/c/gIyvMw0n2qw/m/3XaP6hFpAgAJ

On Thu, Nov 16, 2023 at 5:55 AM Shunya Shishido <sisid...@chromium.org> wrote:
We can wait for more data from the upcoming M120 stable for more confidence, but in that case we need an Intent to Ship instead of this PSA?
As Jeremy mentioned the actual usage is nearly zero, so I believe this change very unlikely breaks sites.
That would be good. In the case where usage shot up more than we were expecting, or are comfortable with, then yes, an I2S would be required.
Also worth noting this feature is Finchable, so in the unlikely event we see a spike in this in stable, we can Finch it off to reconsider before enabling this by default hits the stable channel.
Gotcha.

Shunya Shishido

unread,
Dec 17, 2023, 8:57:37 PM12/17/23
to Mike Taylor, Jeremy Roman, Mathias Bynens, blink-dev
M120 was released about 2 weeks ago, I checked data from Stable.
We don't see any spike on Stable, it's not a zero count but incompatible cases are less than 0.0001% of the entire URL pattern creations, as we expected.

If API owners agree, I believe we can go with PSA.
You can check the raw data with Blink.URLPattern.IncompatiblePatternWithUnicodeSetsMode in the UMA dashboard.
Reply all
Reply to author
Forward
0 new messages