From d6aec9e60b5dad7b6e64b62dc4aa8a9f403634dc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 25 May 2017 16:45:08 +0200 Subject: Selection is now limited to 2k characters using bookmarklets to avoid having too large URL Fixes #528 --- tpl/default/tools.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tpl/default/tools.html') diff --git a/tpl/default/tools.html b/tpl/default/tools.html index 6951ad28..bf6b6ca3 100644 --- a/tpl/default/tools.html +++ b/tpl/default/tools.html @@ -75,7 +75,7 @@ window.open( '{$pageabsaddr}?post='%20+%20encodeURIComponent(url)+ '&title='%20+%20encodeURIComponent(title)+ - '&description='%20+%20encodeURIComponent(document.getSelection())+ + '&description='%20+%20encodeURIComponent(document.getSelection().toString().substr(0, 2000))+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); } @@ -91,7 +91,7 @@ function(){ window.open( '{$pageabsaddr}?private=1&post='+ - '&description='%20+%20encodeURIComponent(document.getSelection())+ + '&description='%20+%20encodeURIComponent(document.getSelection().toString().substr(0, 2000))+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); } -- cgit v1.2.3 From e2bcb9d915fdda15253dd730a6d172323a8e8564 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 28 May 2017 13:04:31 +0200 Subject: Bookmarklet size limit: increase to 4500 chars and add an alert warning --- tpl/default/tools.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tpl/default/tools.html') diff --git a/tpl/default/tools.html b/tpl/default/tools.html index bf6b6ca3..35173d17 100644 --- a/tpl/default/tools.html +++ b/tpl/default/tools.html @@ -72,10 +72,15 @@ function(){ var%20url%20=%20location.href; var%20title%20=%20document.title%20||%20url; + var%20desc=document.getSelection().toString(); + if(desc.length>4000){ + desc=desc.substr(0,4000)+'...'; + alert('{function="str_replace(' ', '%20', t('The selected text is too long, it will be truncated.'))"}'); + } window.open( '{$pageabsaddr}?post='%20+%20encodeURIComponent(url)+ '&title='%20+%20encodeURIComponent(title)+ - '&description='%20+%20encodeURIComponent(document.getSelection().toString().substr(0, 2000))+ + '&description='%20+%20encodeURIComponent(desc)+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); } @@ -89,9 +94,14 @@ class="bookmarklet-link" href="javascript:( function(){ + var%20desc=document.getSelection().toString(); + if(desc.length>4000){ + desc=desc.substr(0,4000)+'...'; + alert("{function="str_replace(' ', '%20', t('The selected text is too long, it will be truncated.'))"}"); + } window.open( '{$pageabsaddr}?private=1&post='+ - '&description='%20+%20encodeURIComponent(document.getSelection().toString().substr(0, 2000))+ + '&description='%20+%20encodeURIComponent(desc)+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); } -- cgit v1.2.3