Commit e2b5693d authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Bypass Closure's SafeHtml for HTML known to be safe

When we updated the Closure Compiler for the Blockly update, some
strings containing HTML were escaped unnecessarily. These strings are
part of internationalization, and so they will be code reviewed before
acceptance into the code base. We therefore break the SafeHtml
contract imposed by Google Closure Library and manipulate the content
element directly so that the static HTML content is preserved.

Fixes #985

Change-Id: I8a545d46aceedcb8039f194ce03a86d924ab0867
parent 157e5944
...@@ -650,7 +650,15 @@ Blockly.ReplMgr.processRetvals = function(responses) { ...@@ -650,7 +650,15 @@ Blockly.ReplMgr.processRetvals = function(responses) {
context.runtimeError.setTitle(Blockly.Msg.REPL_RUNTIME_ERROR); context.runtimeError.setTitle(Blockly.Msg.REPL_RUNTIME_ERROR);
context.runtimeError.setButtonSet(new goog.ui.Dialog.ButtonSet(). context.runtimeError.setButtonSet(new goog.ui.Dialog.ButtonSet().
addButton({caption:Blockly.Msg.REPL_DISMISS}, false, true)); addButton({caption:Blockly.Msg.REPL_DISMISS}, false, true));
context.runtimeError.setTextContent(message); if (context.runtimeError.getContentElement()) {
// This is not condoned by Google Closure Library rules, but we have already escaped
// the return value and the static content should be code reviewed to be safe.
context.runtimeError.getContentElement().innerHTML = message;
} else {
// Fallback option if for some reason the content element did not exist.
// This shouldn't happen in practice, but you never know...
context.runtimeError.setSafeHtmlContent(goog.html.SafeHtml.htmlEscape(message));
}
context.runtimeError.setVisible(true); context.runtimeError.setVisible(true);
}; };
// From http://forums.asp.net/t/1151879.aspx?HttpUtility+HtmlEncode+in+javaScript+ // From http://forums.asp.net/t/1151879.aspx?HttpUtility+HtmlEncode+in+javaScript+
......
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