From 941bc4e7444f1c2042866fff5c29592ab6b28822 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 19 Aug 2024 13:26:15 +0200 Subject: [PATCH 1/2] Make get, decode, and split handle a trailing comma correctly Fixes #1768. --- fetch.bs | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/fetch.bs b/fetch.bs index de4606f20..eb7327f26 100644 --- a/fetch.bs +++ b/fetch.bs @@ -778,30 +778,15 @@ a header value value, run these steps. They return a The result might be the empty string.
  • -

    If position is not past the end of input, then: +

    If position is not past the end of input and the + code point at position within input is U+0022 ("):

      -
    1. -

      If the code point at position within input is - U+0022 ("), then: - -

        -
      1. Append the result of collecting an HTTP quoted string from input, - given position, to temporaryValue. - -

      2. If position is not past the end of input, then - continue. -
      - -
    2. -

      Otherwise: - -

        -
      1. Assert: the code point at position within input is - U+002C (,). +

      2. Append the result of collecting an HTTP quoted string from input, + given position, to temporaryValue. -

      3. Advance position by 1. -

      +
    3. If position is not past the end of input, then + continue.
  • Remove all HTTP tab or space from the start and end of temporaryValue. @@ -809,6 +794,19 @@ a header value value, run these steps. They return a

    Append temporaryValue to values.

  • Set temporaryValue to the empty string. + +

  • +

    If position is not past the end of input: + +

      +
    1. Assert: the code point at position within + input is U+002C (,). + +

    2. Advance position by 1. + +

    3. If position is past the end of input, then append + the empty string to values. +

  • Return values. @@ -9040,6 +9038,7 @@ Brad Porter, Bryan Smith, Caitlin Potter, Cameron McCormack, +Carlo Cannas, 白丞祐 (Cheng-You Bai), Chirag S Kumar, Chris Needham, From 03345042f172269165987b247a3e23706772a18d Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 19 Aug 2024 15:37:35 +0200 Subject: [PATCH 2/2] Also return an empty string value when a header has no value but is present --- fetch.bs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/fetch.bs b/fetch.bs index eb7327f26..ccaef810b 100644 --- a/fetch.bs +++ b/fetch.bs @@ -698,6 +698,19 @@ A: nosniff B: sniff A: + + +

    
    +A:
    +B: sniff
    +
    + « "" » + + +
    
    +B: sniff
    +
    + null
    A: text/html;", x/x
    @@ -763,12 +776,12 @@ a header value value, run these steps. They return a

    Let position be a position variable for input, initially pointing at the start of input. -

  • Let values be a list of strings, initially empty. +

  • Let values be a list of strings, initially « ».

  • Let temporaryValue be the empty string.

  • -

    While position is not past the end of input: +

    While true:

    1. @@ -795,21 +808,13 @@ a header value value, run these steps. They return a

      Set temporaryValue to the empty string. -

    2. -

      If position is not past the end of input: - -

        -
      1. Assert: the code point at position within - input is U+002C (,). +

      2. If position is past the end of input, then return values. -

      3. Advance position by 1. +

      4. Assert: the code point at position within + input is U+002C (,). -

      5. If position is past the end of input, then append - the empty string to values. -

      +
    3. Advance position by 1.

    - -
  • Return values.

    Except for blessed call sites, the algorithm directly above is not to be invoked