<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>179475</bug_id>
          
          <creation_ts>2017-11-09 05:09:35 -0800</creation_ts>
          <short_desc>[SOUP] Case of request headers depends on global state in libsoup</short_desc>
          <delta_ts>2021-07-03 06:56:07 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=177530</see_also>
    
    <see_also>https://bugzilla.gnome.org/show_bug.cgi?id=792176</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ms2ger (he/him; ⌚ UTC+1/+2)">Ms2ger</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>clopez</cc>
    
    <cc>csaavedra</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1369850</commentid>
    <comment_count>0</comment_count>
    <who name="Ms2ger (he/him; ⌚ UTC+1/+2)">Ms2ger</who>
    <bug_when>2017-11-09 05:09:35 -0800</bug_when>
    <thetext>http://w3c-test.org/fetch/api/basic/request-headers-case.any.html

soup_message_headers_append interns the header name case-insensitively, and always uses the casing it got in the first call. This means that

fetch(&quot;..&quot;, {headers: [[&quot;TEST&quot;, 1]] })
fetch(&quot;..&quot;, {headers: [[&quot;test&quot;, 1]] })

will the same header name twice. The name might be &quot;TEST&quot;, or it might be any other casing which any other web page has used during the runtime of the browser.

This also provides a way of cross-origin communication: if a web page A uses a sufficiently unique header name in a particular casing, another web page B can check if page A was loaded before page B by checking what happens when using the header name in a different casing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1369866</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-11-09 07:44:17 -0800</bug_when>
    <thetext>Wow, good find!

I don&apos;t think there is anything to change in WebKit here. Do you want to report this on GNOME Bugzilla?

Anyway, the fix would surely be in soup-message-headers.c:

static const char *
intern_header_name (const char *name, SoupHeaderSetter *setter)
{
	// ...

	if (!header_pool) {
		header_pool = g_hash_table_new (soup_str_case_hash, soup_str_case_equal);

	// ...
}

Presumably that would need to be changed to:

	header_pool = g_hash_table_new (g_str_hash, g_str_equal);

But we should probably audit other uses of soup_str_case_hash and soup_str_case_equal to ensure they are appropriate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1369873</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-11-09 08:20:17 -0800</bug_when>
    <thetext>danw	the &quot;cross-origin communication&quot; idea seems a little crazy, but people have done crazier stuff... I&apos;d say file a libsoup bug yeah. you can&apos;t just change intern_header_name to be non-case-sensitive though. that would definitely break things
mcatanzaro	What sort of things?
danw	eg, when you call soup_message_headers_get_content_type(), it has to return the content type whether it was specified as &quot;Content-Type&quot; or &quot;CONTENT-type&quot;
I guess if you want to fix it, the fix would be to not intern header names at all. just copy both name and value, and use g_ascii_strcasecmp() rather than pointer equality to compare header names when needed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1379102</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-12-07 07:58:29 -0800</bug_when>
    <thetext>This is a bug in libsoup, not in WebKit. This report needs to be moved to GNOME Bugzilla.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774667</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2021-07-03 06:54:02 -0700</bug_when>
    <thetext>This two tests pass now when webkit is built with libsoup3</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>