netlify / netlify-playground

https://play.netlify.com
MIT License
89 stars 16 forks source link

Incorrect replacement of ":" #29

Closed atnbueno closed 6 years ago

atnbueno commented 6 years ago

- Do you want to request a feature or report a bug?

Bug 🐛

- What is the current behavior?

When I try to test a header that contains the ":" character, it is replaced by " = ", even when it is what goes after an URI scheme and it is between quotes that should protect it 😢

- If the current behavior is a bug, please provide the steps to reproduce.

Test these headers:

/*.md
    Content-Type: text/plain
/*.txt
    Link "<http://mydomain.com/plaintext.css>;rel=stylesheet;type=text/css;media=all"

They are considered valid and equivalent to this TOML output:

[[headers]]
for = "/*.md"
[headers.values]
Content-Type = "text/plain"
[[headers]]
for = "/*.txt"
[headers.values]
Link "<http = "//mydomain.com/plaintext.css>;rel=stylesheet;type=text/css;media=all""

Notice the first ":" replacement is correct, but not the second one 😢 Also the original quotes are ignored and end up doubled.

- What is the expected behavior?

The second ":", the one in "http://", should be left intact. Existing quotes should be detected and not be considered normal characters to be (re-)quoted.

- Please mention your Elm, node.js, and operating system version.

🤷 Firefox + Windows 10

calavera commented 6 years ago

@atnbueno Thanks for reporting this issue. I noticed that you second rule has a typo, it doesn't include a colon : after Link, that's why the equal sign is missplaced. However, the double quotation is a real issue. I've opened #31 that fixes this problem.