[Pkg-javascript-commits] [less.js] 19/50: Added condition to check if HEX code contain only valid characters

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:22:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.1
in repository less.js.

commit 31ffdb8c9f5b15bdfc82640eb58d0b55d79fa57c
Author: Ondřej Macoszek <ondra at macoszek.cz>
Date:   Tue Apr 15 13:20:04 2014 +0200

    Added condition to check if HEX code contain only valid characters
---
 lib/less/parser.js                           | 6 ++++++
 test/less/errors/color-invalid-hex-code.less | 3 +++
 test/less/errors/color-invalid-hex-code.txt  | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/lib/less/parser.js b/lib/less/parser.js
index 9a1bf7e..b1e24e9 100644
--- a/lib/less/parser.js
+++ b/lib/less/parser.js
@@ -960,6 +960,12 @@ less.Parser = function Parser(env) {
                     var rgb;
 
                     if (input.charAt(i) === '#' && (rgb = $re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
+                        if (rgb[1].length === 3) {
+                            var followingCharacter = rgb.input.substring(4,5);
+                            if (followingCharacter.match(/[A-Za-z]{1}/)) {
+                                error("Some characters in HEX code are not valid. (see issue #1015)");
+                            }
+                        }
                         return new(tree.Color)(rgb[1]);
                     }
                 },
diff --git a/test/less/errors/color-invalid-hex-code.less b/test/less/errors/color-invalid-hex-code.less
new file mode 100644
index 0000000..0e6c5de
--- /dev/null
+++ b/test/less/errors/color-invalid-hex-code.less
@@ -0,0 +1,3 @@
+.a {
+    @wrongHEXColorCode: #DCALLB;
+}
\ No newline at end of file
diff --git a/test/less/errors/color-invalid-hex-code.txt b/test/less/errors/color-invalid-hex-code.txt
new file mode 100644
index 0000000..77e29f0
--- /dev/null
+++ b/test/less/errors/color-invalid-hex-code.txt
@@ -0,0 +1,4 @@
+SyntaxError: Some characters in HEX code are not valid. (see issue #1015) in {path}color-invalid-hex-code.less on line 2, column 29:
+1 .a {
+2     @wrongHEXColorCode: #DCALLB;
+3 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list