From e8fce62467a421132f4ebb6ca9c0926b623ec00e Mon Sep 17 00:00:00 2001
Message-Id: <e8fce62467a421132f4ebb6ca9c0926b623ec00e.1574338687.git.pmatilai@redhat.com>
From: Panu Matilainen <pmatilai@redhat.com>
Date: Tue, 27 Nov 2018 13:40:21 +0200
Subject: [PATCH 1/2] Consolidate allowed version/release/evr allowed
characters to macros
Maintaining multiple variants of the same thing, that always worked
soooooo well... No functional changes here. Unless I truly messed up.
---
build/parsePreamble.c | 2 +-
build/parseReqs.c | 2 +-
build/rpmbuild_internal.h | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 2d54abeee..f5e06bac8 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -772,7 +772,7 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
case RPMTAG_VERSION:
case RPMTAG_RELEASE:
SINGLE_TOKEN_ONLY;
- if (rpmCharCheck(spec, field, "._+%{}~"))
+ if (rpmCharCheck(spec, field, WHITELIST_VERREL))
goto exit;
headerPutString(pkg->header, tag, field);
break;
diff --git a/build/parseReqs.c b/build/parseReqs.c
index 2201eebf1..9b081a5ff 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -57,7 +57,7 @@ static rpmRC checkDep(rpmSpec spec, char *N, char *EVR, char **emsg)
rasprintf(emsg, _("Versioned file name not permitted"));
return RPMRC_FAIL;
}
- if (rpmCharCheck(spec, EVR, ".-_+:%{}~"))
+ if (rpmCharCheck(spec, EVR, WHITELIST_EVR))
return RPMRC_FAIL;
if (checkSep(EVR, '-', emsg) != RPMRC_OK ||
checkSep(EVR, ':', emsg) != RPMRC_OK ||
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 86cc549a7..f758e6620 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -18,6 +18,8 @@
#undef HTDATATYPE
#define WHITELIST_NAME ".-_+%{}"
+#define WHITELIST_VERREL "._+%{}~"
+#define WHITELIST_EVR WHITELIST_VERREL "-:"
struct TriggerFileEntry {
int index;
--
2.23.0