summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/prototype/string.js
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/prototype/string.js')
-rw-r--r--framework/Web/Javascripts/prototype/string.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/prototype/string.js b/framework/Web/Javascripts/prototype/string.js
index c869e7db..f7b74710 100644
--- a/framework/Web/Javascripts/prototype/string.js
+++ b/framework/Web/Javascripts/prototype/string.js
@@ -3,6 +3,22 @@ Object.extend(String.prototype, {
return this.replace(/<\/?[^>]+>/gi, '');
},
+ stripScripts: function() {
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+ },
+
+ extractScripts: function() {
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+ return (this.match(matchAll) || []).map(function(scriptTag) {
+ return (scriptTag.match(matchOne) || ['', ''])[1];
+ });
+ },
+
+ evalScripts: function() {
+ return this.extractScripts().map(eval);
+ },
+
escapeHTML: function() {
var div = document.createElement('div');
var text = document.createTextNode(this);