mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 06:48:47 +02:00
Make sure shellescape() does not mangle UTF-8 characters.
This commit is contained in:
12
src/utils.c
12
src/utils.c
@@ -165,11 +165,15 @@ int _private_sub_overflow(int a, int b)
|
||||
int
|
||||
ShellEscape(char const *in, DynamicBuffer *out)
|
||||
{
|
||||
while(*in) {
|
||||
if (!strchr(DontEscapeMe, *in)) {
|
||||
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
|
||||
unsigned char const *i = (unsigned char const *) in;
|
||||
while(*i) {
|
||||
/* Don't escape chars with high bit set. That will mangle UTF-8 */
|
||||
if (! (*i & 0x80) ) {
|
||||
if (!strchr(DontEscapeMe, *i)) {
|
||||
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
if (DBufPutc(out, *in++) != OK) return E_NO_MEM;
|
||||
if (DBufPutc(out, *i++) != OK) return E_NO_MEM;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -4972,6 +4972,13 @@ trigtime() => 16:00
|
||||
../tests/test.rem(940): Trig = Tuesday, 19 February, 1991 AT 10:00 DURATION 16:00
|
||||
../tests/test.rem(940): Trig = Tuesday, 19 February, 1991 AT 10:00 DURATION 16:00
|
||||
|
||||
# Make sure shellescape does not mangle UTF-8 characters
|
||||
msg [shellescape("😆")]
|
||||
../tests/test.rem(943): Trig = Saturday, 16 February, 1991
|
||||
shellescape("😆") => "😆"
|
||||
😆
|
||||
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
|
||||
@@ -939,6 +939,9 @@ REM Tue AT 10:00 DURATION [$Tt] MSG blort
|
||||
REM Tue AT 16:00 MSG blort
|
||||
REM Tue AT 10:00 DURATION [trigtime()] MSG blort
|
||||
|
||||
# Make sure shellescape does not mangle UTF-8 characters
|
||||
msg [shellescape("😆")]
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user