From ec7151c72b9b450cdfdffa167bdf8461e77660f1 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 20 Sep 2023 15:54:17 +0300 Subject: [PATCH 1/5] Specify URL encoding for links - Use the document encoding for link elements - Always use UTF8 for link headers/early hints Closes #9715 --- source | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source b/source index 73646634775..ee0804c4a4f 100644 --- a/source +++ b/source @@ -15548,9 +15548,10 @@ interface HTMLLinkElement : HTMLElement { a destination, then return null.

  • -

    Let url be the result of encoding-parsing a URL given - options's href, relative to - options's base URL.

    +

    Let url be the result of applying the URL parser to + options's href, with + options's base URL and + options's encoding.

    Passing the base URL instead of a document or environment is tracked by issue #9715.

    @@ -15648,6 +15649,9 @@ interface HTMLLinkElement : HTMLElement {
    base URL
    A URL
    +
    encoding (default UTF-8)
    +
    An encoding
    +
    origin
    An origin
    @@ -15701,6 +15705,10 @@ interface HTMLLinkElement : HTMLElement {
    base URL
    document's document base URL
    +
    encoding
    +
    document's character encoding
    +
    origin
    document's origin
    From 3d547217a04fffbe1a943a445fd7af915835e877 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 21 Sep 2023 09:36:49 +0300 Subject: [PATCH 2/5] Branch inside parse code instead --- source | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/source b/source index ee0804c4a4f..84a115f1691 100644 --- a/source +++ b/source @@ -7086,8 +7086,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    To encoding-parse a URL, - given a string url, relative to a Document object or environment - settings object environment, run these steps. They return failure or a + given a string url, relative to a Document object or + environment environment, run these steps. They return failure or a URL.

      @@ -7097,15 +7097,17 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute to environment's character encoding.

      -
    1. Otherwise, if environment's relevant global object is a - Window object, set encoding to environment's relevant - global object's associated - Document's character - encoding.

    2. +
    3. Otherwise, if environment is an environment settings object and + environment's relevant global object is a Window object, set + encoding to environment's relevant global object's associated Document's character encoding.

    4. Let baseURL be environment's base URL, if environment is a Document object; otherwise - environment's API base URL.

    5. + environment's API base URL, if environment is an + environment settings object; otherwise environment's creation URL.

    6. Return the result of applying the URL parser to url, with baseURL and encoding.

    7. @@ -15548,10 +15550,10 @@ interface HTMLLinkElement : HTMLElement { a destination, then return null.

    8. -

      Let url be the result of applying the URL parser to - options's href, with - options's base URL and - options's encoding.

      +

      Let url be the result of encoding-parse a URL given + options's href and options's + environment.

      Passing the base URL instead of a document or environment is tracked by issue #9715.

      @@ -15649,9 +15651,6 @@ interface HTMLLinkElement : HTMLElement {
      base URL
      A URL
      -
      encoding (default UTF-8)
      -
      An encoding
      -
      origin
      An origin
      @@ -15705,10 +15704,6 @@ interface HTMLLinkElement : HTMLElement {
      base URL
      document's document base URL
      -
      encoding
      -
      document's character encoding
      -
      origin
      document's origin
      From cc88336167f51299614fe1c32e88dfab09f3823f Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 25 Sep 2023 18:40:00 +0300 Subject: [PATCH 3/5] Refactor out link-options-base-url --- source | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/source b/source index 84a115f1691..9508c9d9801 100644 --- a/source +++ b/source @@ -15648,9 +15648,6 @@ interface HTMLLinkElement : HTMLElement {
      source set (default null)
      Null or a source set
      -
      base URL
      -
      A URL
      -
      origin
      An origin
      @@ -15671,11 +15668,6 @@ interface HTMLLinkElement : HTMLElement {
      A fetch priority attribute state
      -

      A link processing options has a base URL and an href - rather than a parsed URL because the URL could be a result of the options's source set.

      -

      To create link options from element given a link element el:

      @@ -15701,9 +15693,6 @@ interface HTMLLinkElement : HTMLElement {
      source set
      el's source set
      -
      base URL
      -
      document's document base URL
      -
      origin
      document's origin
      @@ -15820,9 +15809,6 @@ interface HTMLLinkElement : HTMLElement {
      href
      linkObject["target_uri"]
      -
      base URL
      -
      doc's document base URL
      -
      origin
      doc's origin
      @@ -16014,9 +16000,6 @@ data-x="rel-preload">preload; as=font<
      initiator
      "early-hint"
      -
      base URL
      -
      response's URL
      -
      origin
      response's URL's origin
      @@ -26863,16 +26846,11 @@ document.body.appendChild(wbr);
      1. If options's - href is an empty string, returns.

      2. - -
      3. -

        Let url be the result of encoding-parsing a URL given - options's href, relative to - options's base URL.

        + href is an empty string, return.

      4. -

        Passing the base URL instead of a document or environment is tracked by issue #9715.

        - +
      5. Let url be the result of encoding-parsing a URL given + options's href, relative to + options's environment.

      6. If url is failure, then return.

      7. From 3ac7a900f928233cf01028ad5ee3a0d38a7e9c8f Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 25 Sep 2023 19:47:48 +0300 Subject: [PATCH 4/5] nits --- source | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/source b/source index 9508c9d9801..6d17ec6d134 100644 --- a/source +++ b/source @@ -15549,15 +15549,10 @@ interface HTMLLinkElement : HTMLElement {
      8. If options's destination is not a destination, then return null.

      9. -
      10. -

        Let url be the result of encoding-parse a URL given - options's href and options's - environment.

        - -

        Passing the base URL instead of a document or environment is tracked by issue #9715.

        -
      11. +
      12. Let url be the result of encoding-parse a URL given + options's href, relative to + options's environment.

      13. If url is failure, then return null.

      14. @@ -26845,8 +26840,8 @@ document.body.appendChild(wbr);

        To preconnect given a link processing options options:

          -
        1. If options's - href is an empty string, return.

        2. +
        3. If options's href is an empty string, + then return.

        4. Let url be the result of encoding-parsing a URL given options's href, relative to From 560917f448b4601ea0af737894b6c5f06f7d0af8 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 28 Sep 2023 09:15:41 +0300 Subject: [PATCH 5/5] nit --- source | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source b/source index 6d17ec6d134..c637849e13e 100644 --- a/source +++ b/source @@ -15549,8 +15549,7 @@ interface HTMLLinkElement : HTMLElement {

        5. If options's destination is not a destination, then return null.

        6. -
        7. Let url be the result of encoding-parse a URL given +

        8. Let url be the result of encoding-parsing a URL given options's href, relative to options's environment.