Re: [PATCH 16/21] Introduce optional "keywords" on tag objects

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 16/21] Introduce optional "keywords" on tag objects

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:15

"Alex Riesen" [off-list ref] writes:
On 6/9/07, Johan Herland [off-list ref] wrote:
quoted
This patch introduces a new optional header line to the tag object, called
"keywords". The "keywords" line may contain a comma-separated list of
custom keywords associated with the tag object.
What is the character set for the keywords?
quoted
+                       for (i = 0; i < keywords_len; ++i) {
+                               unsigned char c = keywords_line[i];
+                               if (c == ',' && keywords_line[i + 1] == ',')
+                                       /* consecutive commas */
+                                       return error("Tag object (@ char "
+                                               PD_FMT "): Found empty keyword",
+                                               keywords_line + i - data);
+                               if (c > ' ' && c != 0x7f)
+                                       continue;
And what is so special about 0x7f?
It is DEL, but as the code uses uchar, it probably also error on
0x80 or higher, if the intent is "printable ASCII".

[PATCH] Fail if tag name and keywords is not within "printable ASCII"

From: Johan Herland <hidden>
Date: 2016-06-15 22:43:15

Signed-off-by: Johan Herland <redacted>
---

On Sunday 10 June 2007, Junio C Hamano wrote:
"Alex Riesen" [off-list ref] writes:
quoted
And what is so special about 0x7f?
It is DEL, but as the code uses uchar, it probably also error on
0x80 or higher, if the intent is "printable ASCII".
Is this better?


...Johan

 tag.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tag.c b/tag.c
index 2307ec9..2b92465 100644
--- a/tag.c
+++ b/tag.c
@@ -183,8 +183,8 @@ int parse_and_verify_tag_buffer(struct tag *item,
 		/* Verify tag name: disallow control characters or spaces */
 		if (tag_len) { /* tag name was given */
 			for (i = 0; i < tag_len; ++i) {
-				unsigned char c = tag_line[i];
-				if (c > ' ' && c != 0x7f)
+				char c = tag_line[i];
+				if (c > ' ' && c < 0x7f)
 					continue;
 				return FAIL("Tag object (@ char " PD_FMT "): "
 					"Could not verify tag name",
@@ -198,13 +198,13 @@ int parse_and_verify_tag_buffer(struct tag *item,
 		 */
 		if (keywords_len) { /* keywords line was given */
 			for (i = 0; i < keywords_len; ++i) {
-				unsigned char c = keywords_line[i];
+				char c = keywords_line[i];
 				if (c == ',' && keywords_line[i + 1] == ',')
 					/* consecutive commas */
 					return FAIL("Tag object (@ char "
 						PD_FMT "): Found empty keyword",
 						keywords_line + i - data);
-				if (c > ' ' && c != 0x7f)
+				if (c > ' ' && c < 0x7f)
 					continue;
 				return FAIL("Tag object (@ char " PD_FMT "): "
 					"Could not verify keywords",
-- 
1.5.2.1.144.gabc40

	
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help