Skip to content

Commit b181676

Browse files
rscharfegitster
authored andcommitted
convert: fix handling of dashless UTF prefix in validate_encoding()
Strip "UTF" and an optional dash from the start of 'upper' without passing a NULL pointer to skip_prefix() in the second call, as it cannot handle that. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit b181676

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

convert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ static int validate_encoding(const char *path, const char *enc,
289289
const char *stripped = NULL;
290290
char *upper = xstrdup_toupper(enc);
291291
upper[strlen(upper)-2] = '\0';
292-
if (!skip_prefix(upper, "UTF-", &stripped))
293-
skip_prefix(stripped, "UTF", &stripped);
292+
if (skip_prefix(upper, "UTF", &stripped))
293+
skip_prefix(stripped, "-", &stripped);
294294
advise(advise_msg, path, stripped);
295295
free(upper);
296296
if (die_on_error)
@@ -309,8 +309,8 @@ static int validate_encoding(const char *path, const char *enc,
309309
"working-tree-encoding.");
310310
const char *stripped = NULL;
311311
char *upper = xstrdup_toupper(enc);
312-
if (!skip_prefix(upper, "UTF-", &stripped))
313-
skip_prefix(stripped, "UTF", &stripped);
312+
if (skip_prefix(upper, "UTF", &stripped))
313+
skip_prefix(stripped, "-", &stripped);
314314
advise(advise_msg, path, stripped, stripped);
315315
free(upper);
316316
if (die_on_error)

0 commit comments

Comments
 (0)