]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #884 from ArthurHoaro/hotfix/bookmarklet-url-limit
authorArthurHoaro <arthur@hoa.ro>
Wed, 31 May 2017 15:44:19 +0000 (17:44 +0200)
committerGitHub <noreply@github.com>
Wed, 31 May 2017 15:44:19 +0000 (17:44 +0200)
Selection is now limited to 2k characters using bookmarklets

tpl/default/tools.html

index 6951ad28b6a8d29c4d8edbccff3f7730926d81c4..35173d179144aab4bac64494cd2e4177e13f61f2 100644 (file)
           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)+
               '&amp;title='%20+%20encodeURIComponent(title)+
-              '&amp;description='%20+%20encodeURIComponent(document.getSelection())+
+              '&amp;description='%20+%20encodeURIComponent(desc)+
               '&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1'
             );
           }
          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&amp;post='+
-              '&amp;description='%20+%20encodeURIComponent(document.getSelection())+
+              '&amp;description='%20+%20encodeURIComponent(desc)+
               '&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1'
             );
           }