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

Re: [PATCH v2] send-email: validate charset name in 8bit encoding prompt

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 24, 2026, 22:06 UTC
Message-ID
<xmqqqzq9er01.fsf@gitster.g>
In-Reply-To
<20260224213932.92364-1-shreyanshpaliwalcmsmn@gmail.com>
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:
Show 43 quoted lines
> When a non-ASCII character is detected in the body or subject of the email
> the user is prompted with,
>
>   Which 8bit encoding should I declare [UTF-8]? foo
>
> After this the input string is validated by the regex, based on the fact
> that the charset string will be minimum 4 characters [1]. If the string is
> more than 4 letters the email is sent, if not then a second prompt to
> confirm is asked to the user,
>
>   Are you sure you want to use <foo> [y/N]? y
>
> This relies on a length based regex heuristic check to validate the user
> input, and can allow clearly invalid charset names to pass if the input is
> greater than 4 characters.
>
> Add a semantic validation of the charset name using the
> Encode::find_encoding() module of perl. If the encoding is not recognized,
> warn the user and ask for confirmation before proceeding. After this
> validation the lenght based validation becomes redundant and also breaks
> flow, so change the regex of valid input to any non blank string.
>
> Additionally, the wording of the first prompt can confuse the user if not
> read properly or under any default assumptions for a yes/no prompt. Change
> the wording to make it explicitly clear to the user that the prompt needs a
> string input, UTF-8 being the default.
>
> The intended flow is,
>
>   Declare which 8bit encoding to use [default: UTF-8]? foobar
>   warning: 'foobar' does not appear to be a valid charset name.
>   Are you sure you want to use <foobar> [y/N]?
>
> [1]- https://github.com/git/git/commit/852a15d748034eec87adbee73a72689c8936fb8b
>
> Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
> ---
> Changes in v2:
>  - Added braces in if-else block.
>
>  git-send-email.perl   | 17 ++++++++++++++---
>  t/t9001-send-email.sh |  2 +-
>  2 files changed, 15 insertions(+), 4 deletions(-)

Curious. This change to t9001 was there even in the previous iteration that did not even work. How did you test it?

Will replace.
Previous: Shreyansh PaliwalNext: Shreyansh Paliwal
Message 15 of 27 in “[RFC] send-email: UTF-8 encoding in subject line”
  1. Shreyansh PaliwalFeb 20, 2026
  2. Ben KnobleFeb 21, 2026
  3. Shreyansh PaliwalFeb 21, 2026
  4. Junio C HamanoFeb 21, 2026
  5. Shreyansh PaliwalFeb 22, 2026
  6. D. Ben KnobleFeb 22, 2026
  7. Shreyansh PaliwalFeb 22, 2026
  8. Ben KnobleFeb 23, 2026
  9. Shreyansh PaliwalFeb 24, 2026
  10. Philip OakleyFeb 22, 2026
  11. D. Ben KnobleFeb 22, 2026
  12. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 24, 2026
  13. Junio C HamanoFeb 24, 2026
  14. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 24, 2026
  15. Junio C HamanoFeb 24, 2026
  16. Shreyansh PaliwalFeb 24, 2026
  17. D. Ben KnobleFeb 25, 2026
  18. Shreyansh PaliwalFeb 26, 2026
  19. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 26, 2026
  20. Junio C HamanoFeb 26, 2026
  21. Junio C HamanoFeb 26, 2026
  22. Shreyansh PaliwalFeb 28, 2026
  23. Shreyansh PaliwalFeb 28, 2026
  24. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 28, 2026
  25. D. Ben KnobleFeb 28, 2026
  26. Junio C HamanoMar 2, 2026
  27. Shreyansh PaliwalMar 3, 2026

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.