Fossil SCM
Check that the value of the "data-copylength" attribute is a positive number prior to chopping the text.
Commit
b9823751c95cc96fa808b4826eef7637de3dd7935c25236766473fddd4195cad
Parent
2e17a063a25575f…
1 file changed
+4
-2
+4
-2
| --- src/copybtn.js | ||
| +++ src/copybtn.js | ||
| @@ -35,12 +35,14 @@ | ||
| 35 | 35 | this.style.opacity = 0; |
| 36 | 36 | var idTarget = this.getAttribute("data-copytarget"); |
| 37 | 37 | var elTarget = document.getElementById(idTarget); |
| 38 | 38 | if( elTarget ){ |
| 39 | 39 | 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 | + } | |
| 42 | 44 | copyTextToClipboard(text); |
| 43 | 45 | } |
| 44 | 46 | setTimeout(function(id){ |
| 45 | 47 | var elButton = document.getElementById(id); |
| 46 | 48 | if( elButton ){ |
| 47 | 49 |
| --- 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 |