⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285810 in webkit


Ignore:
Timestamp:
Nov 15, 2021, 10:36:44 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Null bytes aren't percent-encoded on urlencoded over POST
https://bugs.webkit.org/show_bug.cgi?id=220780

Patch by Andreu Botella <andreu@andreubotella.com> on 2021-11-15
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/forms/form-submission-0/urlencoded2.window-expected.txt:

Source/WebCore:

This change fixes a bug where strchr was being used to match a character against a set
character list, without checking whether the character was NUL. This resulted in NUL bytes
being passed through in the urlencoded enctype over POST, rather than being percent-escaped.

Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/urlencoded2.window.html

  • platform/network/FormDataBuilder.cpp:

(WebCore::FormDataBuilder::appendFormURLEncoded):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r285808 r285810  
     12021-11-15  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Null bytes aren't percent-encoded on urlencoded over POST
     4        https://bugs.webkit.org/show_bug.cgi?id=220780
     5
     6        Reviewed by Alex Christensen.
     7
     8        * web-platform-tests/html/semantics/forms/form-submission-0/urlencoded2.window-expected.txt:
     9
    1102021-11-15  Andreu Botella  <andreu@andreubotella.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/urlencoded2.window-expected.txt

    r280310 r285810  
    44PASS application/x-www-form-urlencoded: Basic File test (normal form)
    55FAIL application/x-www-form-urlencoded: Basic File test (formdata event) assert_equals: expected "basic=file-test.txt" but got ""
    6 FAIL application/x-www-form-urlencoded: 0x00 in name (normal form) assert_equals: expected "a%00b=c" but got "a\0b=c"
    7 FAIL application/x-www-form-urlencoded: 0x00 in name (formdata event) assert_equals: expected "a%00b=c" but got "a\0b=c"
    8 FAIL application/x-www-form-urlencoded: 0x00 in value (normal form) assert_equals: expected "a=b%00c" but got "a=b\0c"
    9 FAIL application/x-www-form-urlencoded: 0x00 in value (formdata event) assert_equals: expected "a=b%00c" but got "a=b\0c"
    10 FAIL application/x-www-form-urlencoded: 0x00 in filename (normal form) assert_equals: expected "a=b%00c" but got "a=b\0c"
     6PASS application/x-www-form-urlencoded: 0x00 in name (normal form)
     7PASS application/x-www-form-urlencoded: 0x00 in name (formdata event)
     8PASS application/x-www-form-urlencoded: 0x00 in value (normal form)
     9PASS application/x-www-form-urlencoded: 0x00 in value (formdata event)
     10PASS application/x-www-form-urlencoded: 0x00 in filename (normal form)
    1111FAIL application/x-www-form-urlencoded: 0x00 in filename (formdata event) assert_equals: expected "a=b%00c" but got ""
    1212PASS application/x-www-form-urlencoded: \n in name (normal form)
  • trunk/Source/WebCore/ChangeLog

    r285808 r285810  
     12021-11-15  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Null bytes aren't percent-encoded on urlencoded over POST
     4        https://bugs.webkit.org/show_bug.cgi?id=220780
     5
     6        Reviewed by Alex Christensen.
     7
     8        This change fixes a bug where strchr was being used to match a character against a set
     9        character list, without checking whether the character was NUL. This resulted in NUL bytes
     10        being passed through in the urlencoded enctype over POST, rather than being percent-escaped.
     11
     12        Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/urlencoded2.window.html
     13
     14        * platform/network/FormDataBuilder.cpp:
     15        (WebCore::FormDataBuilder::appendFormURLEncoded):
     16
    1172021-11-15  Andreu Botella  <andreu@andreubotella.com>
    218
  • trunk/Source/WebCore/platform/network/FormDataBuilder.cpp

    r278619 r285810  
    9191    for (size_t i = 0; i < length; ++i) {
    9292        auto character = string[i];
    93         if (isASCIIAlphanumeric(character) || strchr(safeCharacters, character))
     93        if (isASCIIAlphanumeric(character)
     94            || (character != '\0' && strchr(safeCharacters, character)))
    9495            append(buffer, character);
    9596        else if (character == ' ')
Note: See TracChangeset for help on using the changeset viewer.