digitalpoint
Well-known member
- Affected version
- 2.2.9
Ran into an issue where a proxy system would throw an invalid content type error. It turns out it's because the contentType() method is doing a regex on what it considers a valid content type like so:
A Content-Type header can in fact also have a semi-colon with additional info (which was causing the problem for me). To work around it, I ended up dropping the semi-colon and anything after, but it's probably not the "right" thing to do.
PHP:
if (!preg_match('#^[a-zA-Z0-9]+/[a-zA-Z0-9-+]+$#', $contentType))
{
throw new \InvalidArgumentException('Invalid content type');
}
A Content-Type header can in fact also have a semi-colon with additional info (which was causing the problem for me). To work around it, I ended up dropping the semi-colon and anything after, but it's probably not the "right" thing to do.
Content-Type - HTTP | MDN
The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied for sending).
developer.mozilla.org
Syntax
Content-Type: text/html; charset=UTF-8
Content-Type: multipart/form-data; boundary=something
Directives
media-type
The MIME type of the resource or the data.
charset
The character encoding standard.
boundary
For multipart entities the boundary directive is required. The directive consists of 1 to 70 characters from a set of characters (and not ending with white space) known to be very robust through email gateways. It is used to encapsulate the boundaries of the multiple parts of the message. Often, the header boundary is prepended with two dashes and the final boundary has two dashes appended at the end.