mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
shared: end string with % if one was found at the end of a expandible string (#6828)
Current behavior is that %X where X is an unidentified specifier, then the result is the same %X string. This was not the case when the string ended with a stray %, where the character would have not been output. Lets add that missing character. Fixes: #6374
This commit is contained in:
parent
8b5c528ce8
commit
038492aed3
@ -107,6 +107,10 @@ int specifier_printf(const char *text, const Specifier table[], void *userdata,
|
||||
*(t++) = *f;
|
||||
}
|
||||
|
||||
/* if string ended with a stray %, also end with % */
|
||||
if (percent)
|
||||
*(t++) = '%';
|
||||
|
||||
*t = 0;
|
||||
*_ret = ret;
|
||||
return 0;
|
||||
|
@ -237,7 +237,8 @@ static int test_unit_printf(void) {
|
||||
/* general tests */
|
||||
expect(u, "%%", "%");
|
||||
expect(u, "%%s", "%s");
|
||||
expect(u, "%", ""); // REALLY?
|
||||
expect(u, "%,", "%,");
|
||||
expect(u, "%", "%");
|
||||
|
||||
/* normal unit */
|
||||
expect(u, "%n", "blah.service");
|
||||
|
Loading…
Reference in New Issue
Block a user