Commit a5e317f1 authored by Justus Sagemüller's avatar Justus Sagemüller

Escape html control characters in error messages.

Error messages are usually rendered surprisingly clean even without escaping, but in a few cases it went wrong quite badly, in particular the `<<loop>>` error would get rendered as the completely cryptic `<>`.

Also, something like `"one string&quot; &quot;another string" 4` used to give the error message

```
The function ‘"one string" "another string"’ is applied to one argument,
but its type ‘String’ has none
```

This kind of behavior is prevented by escaping the characters `<`, `>` and `&` to `&lt;`, `&gt;` and `&amp;`, respectively.
parent b7716b9f
...@@ -1315,6 +1315,9 @@ formatErrorWithClass :: String -> ErrMsg -> String ...@@ -1315,6 +1315,9 @@ formatErrorWithClass :: String -> ErrMsg -> String
formatErrorWithClass cls = formatErrorWithClass cls =
printf "<span class='%s'>%s</span>" cls . printf "<span class='%s'>%s</span>" cls .
replace "\n" "<br/>" . replace "\n" "<br/>" .
replace "<" "&lt;" .
replace ">" "&gt;" .
replace "&" "&amp;" .
replace useDashV "" . replace useDashV "" .
replace "Ghci" "IHaskell" . replace "Ghci" "IHaskell" .
replace "‘interactive:" "‘" . replace "‘interactive:" "‘" .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment