mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-29 05:24:22 +00:00
Merge commit from fork
This commit is contained in:
1 parent
81cc18264f
commit
61d1b44f6e
4 files changed
+276
-3
No files matched your search
@@ -783,11 +783,21 @@ extension HPACKHeaders {
|
||||
}
|
||||
|
||||
if let headerValue = headerValue {
|
||||
if !Self.isValidPseudoHeaderValue(headerValue) {
|
||||
throw NIOHTTP2Errors.invalidPseudoHeaderValue(name: name, value: headerValue)
|
||||
}
|
||||
return headerValue
|
||||
} else {
|
||||
throw NIOHTTP2Errors.missingPseudoHeader(name)
|
||||
}
|
||||
}
|
||||
|
||||
static func isValidPseudoHeaderValue(_ value: String) -> Bool {
|
||||
// Pseudo-header values must not contain CR, LF, or NUL bytes. These characters could
|
||||
// enable HTTP/2-to-HTTP/1.1 request smuggling when the value is placed into an HTTP/1.1
|
||||
// message (e.g. :path becomes the request-target).
|
||||
!value.utf8.contains(where: { $0 == 0x0A || $0 == 0x0D || $0 == 0x00 })
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPHeaders {
|
||||
|
||||
Reference in new issue
Block a user