Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2008-11-17 16:08:36 +0300
committermattpiwik <matthieu.aubry@gmail.com>2008-11-17 16:08:36 +0300
commit389923e9e554f88dbab1e90cadf06e93b9aa943f (patch)
tree8ea1f41bd7da5f4773b455f17b417d1352619d9f /libs
parent75db65113c2bbb3515f0157fa0d0e75db5efc600 (diff)
- fixing escaping of script tag in referers (xss)
git-svn-id: http://dev.piwik.org/svn/trunk@697 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs')
-rw-r--r--libs/jquery/truncate/jquery.truncate.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/libs/jquery/truncate/jquery.truncate.js b/libs/jquery/truncate/jquery.truncate.js
index 8285e687bf..21e0180352 100644
--- a/libs/jquery/truncate/jquery.truncate.js
+++ b/libs/jquery/truncate/jquery.truncate.js
@@ -1,3 +1,32 @@
-jQuery.fn.truncate=function(max){return this.each(function(){var trail='...';if(jQuery(this).children().length==0)
-{v=jQuery.trim(jQuery(this).text());while(max<v.length){c=v.charAt(max);newStringTruncated=v.substring(0,max)+trail;charToRemove='"';regExp=new RegExp("["+charToRemove+"]","g");vCleaned=v.replace(regExp,"'");html='<span class="truncated" title="'+vCleaned+'">'+newStringTruncated+'</span>';jQuery(this).html(html);break;max--;}}});}; \ No newline at end of file
+jQuery.fn.truncate = function(max) {
+ return this.each(
+ function() {
+ var trail='...';
+ if(jQuery(this).children().length==0) {
+ v=jQuery.trim(jQuery(this).text());
+ while(max<v.length) {
+ c=v.charAt(max);
+ newStringTruncated=v.substring(0,max)+trail;
+ charToRemove='"';
+ regExp=new RegExp("["+charToRemove+"]","g");
+ vCleaned = v
+ .replace(regExp,"&amp;quot;")
+ .replace(/</g, '&amp;lt;')
+ .replace(/>/g, '&amp;gt;');
+ newStringTruncated = newStringTruncated
+ .replace(regExp,"'")
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+ html='<span class="truncated" title="'+vCleaned+'">'+newStringTruncated+'</span>';
+ console.log(vCleaned);
+ console.log(newStringTruncated);
+ console.log(html);
+ jQuery(this).html(html);
+ break;
+ max--;
+ }
+ }
+ }
+ );
+}; \ No newline at end of file