Index: remoting/webapp/base.js |
diff --git a/remoting/webapp/base.js b/remoting/webapp/base.js |
index 17cfc2971f612f3fdb8a5b0f56090bb6e19b20f6..ee909bede327c38f7cac29fcca6f379d5c7ea42e 100644 |
--- a/remoting/webapp/base.js |
+++ b/remoting/webapp/base.js |
@@ -150,6 +150,18 @@ base.urlJoin = function(url, opt_params) { |
}; |
/** |
+ * Convert special characters (e.g. &, < and >) to HTML entities. |
+ * |
+ * @param {string} str |
+ * @return {string} |
+ */ |
+base.escapeHTML = function(str) { |
+ var div = document.createElement('div'); |
+ div.appendChild(document.createTextNode(str)); |
+ return div.innerHTML; |
+}; |
+ |
+/** |
* Promise is a great tool for writing asynchronous code. However, the construct |
* var p = new promise(function init(resolve, reject) { |
* ... // code that fulfills the Promise. |