mirror of
https://github.com/tbamud/tbamud.git
synced 2026-04-30 04:41:51 +02:00
Compare commits
2 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5c688188b | ||
|
|
d627638f56 |
@@ -1722,5 +1722,5 @@ void var_subst(void *go, struct script_data *sc, trig_data *trig,
|
|||||||
left -= len;
|
left -= len;
|
||||||
} /* else if *p .. */
|
} /* else if *p .. */
|
||||||
} /* while *p .. */
|
} /* while *p .. */
|
||||||
buf[sizeof(buf) - 1] = '\0';
|
*buf = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
29
src/genolc.c
29
src/genolc.c
@@ -277,10 +277,7 @@ int sprintascii(char *out, bitvector_t bits)
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* converts illegal filename chars into appropriate equivalents.
|
/* converts illegal filename chars into appropriate equivalents */
|
||||||
* Uses an allowlist: alphanumerics, underscore, hyphen, and dot are kept;
|
|
||||||
* spaces are converted to underscores; all other characters (including shell
|
|
||||||
* metacharacters such as ; | & ` $ > < \n) are silently dropped. */
|
|
||||||
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
||||||
{
|
{
|
||||||
const char *in = str;
|
const char *in = str;
|
||||||
@@ -288,17 +285,21 @@ static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (*in) {
|
while (*in) {
|
||||||
if (isalnum((unsigned char)*in) || *in == '_' || *in == '-' || *in == '.') {
|
switch(*in) {
|
||||||
/* Safe characters kept as-is */
|
case ' ': *out = '_'; out++; break;
|
||||||
*out++ = *in;
|
case '(': *out = '{'; out++; break;
|
||||||
if (++count == maxlen - 1) break;
|
case ')': *out = '}'; out++; break;
|
||||||
} else if (*in == ' ') {
|
|
||||||
/* Spaces become underscores */
|
/* skip the following */
|
||||||
*out++ = '_';
|
case '\'': break;
|
||||||
if (++count == maxlen - 1) break;
|
case '"': break;
|
||||||
}
|
|
||||||
/* All other characters, including shell metacharacters, are dropped */
|
/* Legal character */
|
||||||
|
default: *out = *in; out++;break;
|
||||||
|
}
|
||||||
in++;
|
in++;
|
||||||
|
count++;
|
||||||
|
if (count == maxlen - 1) break;
|
||||||
}
|
}
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user