Fossil SCM

Check that the value of the "data-copylength" attribute is a positive number prior to chopping the text.

florian 2019-05-31 14:44 tooltip-copyhash
Commit b9823751c95cc96fa808b4826eef7637de3dd7935c25236766473fddd4195cad
1 file changed +4 -2
+4 -2
--- src/copybtn.js
+++ src/copybtn.js
@@ -35,12 +35,14 @@
3535
this.style.opacity = 0;
3636
var idTarget = this.getAttribute("data-copytarget");
3737
var elTarget = document.getElementById(idTarget);
3838
if( elTarget ){
3939
var text = elTarget.innerText;
40
- var cchLength = this.getAttribute("data-copylength");
41
- if( cchLength ) text = text.slice(0,cchLength); // Assume single-byte chars.
40
+ var cchLength = parseInt(this.getAttribute("data-copylength"));
41
+ if( !isNaN(cchLength) && cchLength>0 ){
42
+ text = text.slice(0,cchLength); // Assume single-byte chars.
43
+ }
4244
copyTextToClipboard(text);
4345
}
4446
setTimeout(function(id){
4547
var elButton = document.getElementById(id);
4648
if( elButton ){
4749
--- src/copybtn.js
+++ src/copybtn.js
@@ -35,12 +35,14 @@
35 this.style.opacity = 0;
36 var idTarget = this.getAttribute("data-copytarget");
37 var elTarget = document.getElementById(idTarget);
38 if( elTarget ){
39 var text = elTarget.innerText;
40 var cchLength = this.getAttribute("data-copylength");
41 if( cchLength ) text = text.slice(0,cchLength); // Assume single-byte chars.
 
 
42 copyTextToClipboard(text);
43 }
44 setTimeout(function(id){
45 var elButton = document.getElementById(id);
46 if( elButton ){
47
--- src/copybtn.js
+++ src/copybtn.js
@@ -35,12 +35,14 @@
35 this.style.opacity = 0;
36 var idTarget = this.getAttribute("data-copytarget");
37 var elTarget = document.getElementById(idTarget);
38 if( elTarget ){
39 var text = elTarget.innerText;
40 var cchLength = parseInt(this.getAttribute("data-copylength"));
41 if( !isNaN(cchLength) && cchLength>0 ){
42 text = text.slice(0,cchLength); // Assume single-byte chars.
43 }
44 copyTextToClipboard(text);
45 }
46 setTimeout(function(id){
47 var elButton = document.getElementById(id);
48 if( elButton ){
49

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button