Skip to content

Invalid header value check #39684

@szmarczak

Description

@szmarczak

Version

v16.6.0

Platform

Linux solus 5.13.6-190.current #1 SMP PREEMPT Fri Jul 30 17:08:12 UTC 2021 x86_64 GNU/Linux

Subsystem

http

What steps will reproduce the bug?

http.validateHeaderValue('location', '☃')

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

No error.

What do you see instead?

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["location"]
    at __node_internal_captureLargerStackTrace (node:internal/errors:464:5)
    at new NodeError (node:internal/errors:371:5)
    at Object.__node_internal_ [as validateHeaderValue] (node:_http_outgoing:567:11) {
  code: 'ERR_INVALID_CHAR'
}

Additional information

RFC2616:

       OCTET          = <any 8-bit sequence of data>
       CHAR           = <any US-ASCII character (octets 0 - 127)>
       CTL            = <any US-ASCII control character
                        (octets 0 - 31) and DEL (127)>
       CR             = <US-ASCII CR, carriage return (13)>
       LF             = <US-ASCII LF, linefeed (10)>
       SP             = <US-ASCII SP, space (32)>
       HT             = <US-ASCII HT, horizontal-tab (9)>
       CRLF           = CR LF
       LWS            = [CRLF] 1*( SP | HT )

       message-header = field-name ":" [ field-value ]
       field-name     = token
       field-value    = *( field-content | LWS )
       field-content  = <the OCTETs making up the field-value
                        and consisting of either *TEXT or combinations
                        of token, separators, and quoted-string>

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions