Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 'content-type' header value should be valid (invalid media type) #4636

Open
ChrisGitIt opened this issue Jun 13, 2021 · 2 comments
Open

Comments

@ChrisGitIt
Copy link

ChrisGitIt commented Jun 13, 2021

🐞 Bug report

Description

Hi everybody,

I just checked your nice online tool to further improve my webpages, but somehow, I don't understand the following error and think that it is a bug:

hint #1: 'content-type' header value should be valid (invalid media type).
https://*/img/logo.10.svg
Content-Type: image/svg+xml, utf-8

Details

As far as I checked, the "image/svg+xml" is totally valid and seems to be the recommended for *.svg (https://www.w3.org/TR/SVG11/intro.html).

It also seems to be defined like this internally (packages/utils/src/content-type.ts).
I just realised while writing: Might be an issue with the header parser and the "+" sign?

OR is "..., utf-8" not valid content type for SVG? Could not explicitly find any infos on that.

Greatly appreciate any feedback and hope to further improve your project if this is a bug.

Greets,

Chris

@antross
Copy link
Member

antross commented Jun 18, 2021

Thanks for the report @ChrisGitIt!

I think in this case the format you're using to specify the character encoding in the content type header is incorrect. Updating your server config to send this format should work:

Content-Type: image/svg+xml; charset=utf-8

Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type#syntax

Given you've already been looking at the code, if you think you can update the logic to give a more helpful error in this case I'd be happy to review a PR.

@ChrisGitIt
Copy link
Author

Hi @antross and thanks for for your feedback! I got everything corrected.

Given you've already been looking at the code, if you think you can update the logic to give a more helpful error in this case I'd be happy to review a PR.

Just one notice:
When the charset header is not set, the hint is:
hint #: 'content-type' header charset value should be 'utf-8'.

It might be good to change it to
hint #: 'content-type' header charset value should be 'Content-Type: image/svg+xml; charset=utf-8'.

Whereas "Content-Type" can be whatever the hint refers to (=Info Area where the the current content type is visible)

I know, this is micro optimisation, but directly showing the expected header helps everyone that is doing "hand-on" work instead of "read-first".

Anyways, thanks for your time to solve my problem! Keep up the good work! I really like your tool!

Greets,
Chris

@hxlnt hxlnt added the agenda label Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants