-
Notifications
You must be signed in to change notification settings - Fork 27.3k
docs(errorDisplay): encode < and > in error messages
#14033
docs(errorDisplay): encode < and > in error messages
#14033
Conversation
When an error message contains an HTML string (e.g. `$location:nobase` containing `<base>`), it was interpreted as a literal HTML element, instead of text. Error messages are not expected to render as HTML, but we still need to use `.html()` in `errorDisplay`, so that the links created by `errorLinkFilter` are properly displayed. This commit solves this issue by replacing `<`/`>` with `<`/`>`. Related to angular#14016.
docs/app/src/errors.js
Outdated
|
|
||
|
|
||
| .directive('errorDisplay', ['$location', 'errorLinkFilter', function ($location, errorLinkFilter) { | ||
| var encodeAngularBrackets = function (text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encodeAngularBrackets -> encodeHtmlBrackets ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By Angular, @gkalpak means < and > right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "angle brackets" might be more "correct" (and certainly less confusing).
|
This looks good but I wonder if we could save some complexity by simply using a binding (which should do the escaping for us) rather than writing to |
|
@petebacondarwin, we need the HTML (because we want to render TBH, a much simpler workaround would be to change the error message to not include |
|
Nice thanks |


When an error message contains an HTML string (e.g.
$location:nobasecontaining<base>), it was interpreted as a literal HTML element, instead of text. Error messages are not expected to render as HTML, but we still need to use.html()inerrorDisplay, so that the links created byerrorLinkFilterare properly displayed.This commit solves this issue by replacing
</>with</>.Related to #14016.
There is also another commit that adds some tests for the
errorsmodule of the docs app.