git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
BBBeat Bolli <bb@drbeat.li>
Date
May 2, 2024, 11:03 UTC
Message-ID
<20240502110331.6347-3-dev+git@drbeat.li>
In-Reply-To
<20240502110331.6347-1-dev+git@drbeat.li>

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

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 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
Previous: Beat BolliNext: Beat Bolli
Message 3 of 7 in “color: add support for 12-bit RGB colors”
  1. 0/3 color: add support for 12-bit RGB colorsBeat Bolli, May 2, 2024
  2. 1/3 t/t4026-color: remove an extra double quote characterBeat Bolli, May 2, 2024
  3. 2/3 t/t4026-color: add test coverage for invalid RGB colorsBeat Bolli, May 2, 2024
  4. 3/3 color: add support for 12-bit RGB colorsBeat Bolli, May 2, 2024
  5. Junio C HamanoMay 2, 2024
  6. Jeff KingMay 3, 2024
  7. Beat BolliMay 3, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.