Don't double-expand arguments to built-in macros (#311)
Double-expanding the output makes it rather impossible to reliably handle filenames (and other content) with % characters in them. Fixes: #313
This commit is contained in:
parent
b551b256ea
commit
47dbb3e070
|
@ -1166,7 +1166,6 @@ doFoo(MacroBuf mb, int chkexist, int negate, const char * f, size_t fn,
|
|||
char *b = NULL;
|
||||
int verbose = (rpmIsVerbose() != 0);
|
||||
int expand = (g != NULL && gn > 0);
|
||||
int expandagain = 1;
|
||||
|
||||
/* Don't expand %{verbose:...} argument on false condition */
|
||||
if (STREQ("verbose", f, fn) && (verbose == negate))
|
||||
|
@ -1224,7 +1223,6 @@ doFoo(MacroBuf mb, int chkexist, int negate, const char * f, size_t fn,
|
|||
if (expr) {
|
||||
free(buf);
|
||||
b = buf = expr;
|
||||
expandagain = 0;
|
||||
} else {
|
||||
mb->error = 1;
|
||||
}
|
||||
|
@ -1242,11 +1240,7 @@ doFoo(MacroBuf mb, int chkexist, int negate, const char * f, size_t fn,
|
|||
}
|
||||
|
||||
if (b) {
|
||||
if (expandagain) {
|
||||
(void) expandMacro(mb, b, 0);
|
||||
} else {
|
||||
mbAppendStr(mb, b);
|
||||
}
|
||||
mbAppendStr(mb, b);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
|
|
@ -263,6 +263,7 @@ AT_CHECK([
|
|||
runroot rpm --eval "%{dirname}"
|
||||
runroot rpm --eval "%{dirname:}"
|
||||
runroot rpm --eval "%{dirname:dir}"
|
||||
runroot rpm --define '%xxx /hello/%%%%/world' --eval '%{dirname:%xxx}'
|
||||
runroot rpm --eval "%{uncompress}"
|
||||
runroot rpm --eval "%{uncompress:}"
|
||||
runroot rpm --eval "%{getncpus:}"
|
||||
|
@ -273,6 +274,7 @@ runroot rpm --eval "%{dump:foo}"
|
|||
[1],
|
||||
[
|
||||
dir
|
||||
/hello/%%
|
||||
|
||||
],
|
||||
[error: %dirname: argument expected
|
||||
|
|
Loading…
Reference in New Issue