Skip to content

[http2] If 'set-cookie' header is an array of a single string, it's split into individual characters #16452

Closed
@jinwoo

Description

@jinwoo
  • Version: 8.7.0
  • Platform: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
  • Subsystem:

The 'set-cookie' header field can be an array of multiple values. But when it is an array of only one string, the string is split into an array of its individual characters.

E.g.

headers['set-cookie'] = ['mycookie=foo'];

will end up with 12 'set-cookie' fields each of which has 'm', 'y', 'c', 'o',... etc as its value.

I think the bug is in mapToHeaders() function in util.js:

function mapToHeaders(map,

  1. At line 404, isArray is set to true in this case:
    const isArray = Array.isArray(value);
  2. At line 410, value is converted to a single string:
    value = String(value[0]);
  3. But then at line 433, it's again split into individual characters even though it's been already converted to a single string in step 2 above:
    for (var k = 0; k < value.length; k++) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions