Thread (13 messages) 13 messages, 4 authors, 2024-05-03
STALE798d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 2/3] t/t4026-color: add test coverage for invalid RGB colors

From: Beat Bolli <hidden>
Date: 2024-05-02 11:03:59
Subsystem: the rest · Maintainer: Linus Torvalds

Make sure that the RGB color parser rejects invalid characters and
invalid lengths.

Signed-off-by: Beat Bolli <redacted>
---
 t/t4026-color.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
index 37622451fc23..c41138031989 100755
--- a/t/t4026-color.sh
+++ b/t/t4026-color.sh
@@ -140,6 +140,24 @@ test_expect_success 'extra character after attribute' '
 	invalid_color "dimX"
 '
 
+test_expect_success 'non-hex character in RGB color' '
+	invalid_color "#x23456" &&
+	invalid_color "#1x3456" &&
+	invalid_color "#12x456" &&
+	invalid_color "#123x56" &&
+	invalid_color "#1234x6" &&
+	invalid_color "#12345x"
+'
+
+test_expect_success 'wrong number of letters in RGB color' '
+	invalid_color "#1" &&
+	invalid_color "#23" &&
+	invalid_color "#456" &&
+	invalid_color "#789a" &&
+	invalid_color "#bcdef" &&
+	invalid_color "#1234567"
+'
+
 test_expect_success 'unknown color slots are ignored (diff)' '
 	git config color.diff.nosuchslotwilleverbedefined white &&
 	git diff --color
-- 
2.44.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help