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

Incorrect encoding of href attribute values #110

Open
nad opened this issue Aug 30, 2017 · 0 comments
Open

Incorrect encoding of href attribute values #110

nad opened this issue Aug 30, 2017 · 0 comments

Comments

@nad
Copy link

nad commented Aug 30, 2017

Consider the following code:

{-# LANGUAGE OverloadedStrings #-}

module Test where

import Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes as A
import Text.Blaze.Html.Renderer.Pretty

example =
  putStr $ renderHtml $ docTypeHtml $ do
    H.head $ do
      meta ! charset "utf-8"
      H.title "Test"
    body $ do
      a ! A.href "#%41" $ "Link"
      a ! A.id "A" $ "Wrong target"
      a ! A.id "%41" $ "Correct target"

The resulting output:

<!DOCTYPE HTML>

<html>
    <head>
        <meta charset="utf-8">
        <title>
            Test
        </title>
    </head>
    <body>
        <a href="#%41">
            Link
        </a>
        <a id="A">
            Wrong target
        </a>
        <a id="%41">
            Correct target
        </a>
    </body>
</html>

Note that the href attribute value is not properly encoded, it should be #%2541. The value #%41 is interpreted as a link to A, not as a link to %41.

Is the user of blaze-html expected to perform this encoding manually? I didn't find any information about this in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant