Index: remoting/webapp/base.js |
diff --git a/remoting/webapp/base.js b/remoting/webapp/base.js |
index c2bf1a2b54b28a67c9f7422f10887a5dae5bd2e9..87f59473a1e40d598b9abda80df13678fa8e0e1d 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. |