Commit ba754ef
send-email: validate charset name in 8bit encoding prompt
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]- git@852a15d
Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 7c02d39 commit ba754ef
2 files changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
987 | 988 | | |
988 | 989 | | |
989 | 990 | | |
| 991 | + | |
990 | 992 | | |
991 | 993 | | |
992 | 994 | | |
| |||
1005 | 1007 | | |
1006 | 1008 | | |
1007 | 1009 | | |
1008 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1009 | 1019 | | |
1010 | 1020 | | |
1011 | 1021 | | |
| |||
1044 | 1054 | | |
1045 | 1055 | | |
1046 | 1056 | | |
1047 | | - | |
1048 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1049 | 1060 | | |
1050 | 1061 | | |
1051 | 1062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1691 | 1691 | | |
1692 | 1692 | | |
1693 | 1693 | | |
1694 | | - | |
| 1694 | + | |
1695 | 1695 | | |
1696 | 1696 | | |
1697 | 1697 | | |
| |||
0 commit comments