|
|
6cec19 |
From f67be7b6045fb4be42ad226d0054edd685d33b9f Mon Sep 17 00:00:00 2001
|
|
|
6cec19 |
From: Aleš Matěj <amatej@redhat.com>
|
|
|
6cec19 |
Date: Tue, 12 Feb 2019 12:59:14 +0100
|
|
|
6cec19 |
Subject: [PATCH] Consistently produce valid URLs by prepending protocol. (RhBug:1632121)
|
|
|
6cec19 |
|
|
|
6cec19 |
---
|
|
|
6cec19 |
src/mergerepo_c.c | 17 ++---------------
|
|
|
6cec19 |
src/xml_dump.c | 8 ++++++++
|
|
|
6cec19 |
src/xml_dump.h | 8 ++++++++
|
|
|
6cec19 |
src/xml_dump_primary.c | 6 ++++--
|
|
|
6cec19 |
4 files changed, 22 insertions(+), 17 deletions(-)
|
|
|
6cec19 |
|
|
|
6cec19 |
diff --git a/src/mergerepo_c.c b/src/mergerepo_c.c
|
|
|
6cec19 |
index 94b929c..1ae3a9b 100644
|
|
|
6cec19 |
--- a/src/mergerepo_c.c
|
|
|
6cec19 |
+++ b/src/mergerepo_c.c
|
|
|
6cec19 |
@@ -496,17 +496,6 @@ cr_srpm_val_destroy(gpointer data)
|
|
|
6cec19 |
}
|
|
|
6cec19 |
|
|
|
6cec19 |
|
|
|
6cec19 |
-/** Prepend protocol if necessary
|
|
|
6cec19 |
- */
|
|
|
6cec19 |
-static gchar *
|
|
|
6cec19 |
-prepend_protocol(const gchar *url)
|
|
|
6cec19 |
-{
|
|
|
6cec19 |
- if (url && *url == '/')
|
|
|
6cec19 |
- return g_strconcat("file://", url, NULL);
|
|
|
6cec19 |
- return g_strdup(url);
|
|
|
6cec19 |
-}
|
|
|
6cec19 |
-
|
|
|
6cec19 |
-
|
|
|
6cec19 |
int
|
|
|
6cec19 |
koji_stuff_prepare(struct KojiMergedReposStuff **koji_stuff_ptr,
|
|
|
6cec19 |
struct CmdOptions *cmd_options,
|
|
|
6cec19 |
@@ -820,9 +809,7 @@ add_package(cr_Package *pkg,
|
|
|
6cec19 |
if (!list) {
|
|
|
6cec19 |
list = g_slist_prepend(list, pkg);
|
|
|
6cec19 |
if ((!pkg->location_base || *pkg->location_base == '\0') && repopath) {
|
|
|
6cec19 |
- _cleanup_free_ gchar *repopath_with_protocol = NULL;
|
|
|
6cec19 |
- repopath_with_protocol = prepend_protocol(repopath);
|
|
|
6cec19 |
- pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, repopath_with_protocol);
|
|
|
6cec19 |
+ pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, repopath);
|
|
|
6cec19 |
}
|
|
|
6cec19 |
g_hash_table_insert (merged, (gpointer) pkg->name, (gpointer) list);
|
|
|
6cec19 |
return 1;
|
|
|
6cec19 |
@@ -1039,7 +1026,7 @@ merge_repos(GHashTable *merged,
|
|
|
6cec19 |
// Koji-mergerepos specific behaviour -----------
|
|
|
6cec19 |
if (koji_stuff && koji_stuff->pkgorigins) {
|
|
|
6cec19 |
_cleanup_free_ gchar *nvra = cr_package_nvra(pkg);
|
|
|
6cec19 |
- _cleanup_free_ gchar *url = prepend_protocol(ml->original_url);
|
|
|
6cec19 |
+ _cleanup_free_ gchar *url = cr_prepend_protocol(ml->original_url);
|
|
|
6cec19 |
|
|
|
6cec19 |
cr_printf(NULL,
|
|
|
6cec19 |
koji_stuff->pkgorigins,
|
|
|
6cec19 |
diff --git a/src/xml_dump.c b/src/xml_dump.c
|
|
|
6cec19 |
index 3fbb422..7a93231 100644
|
|
|
6cec19 |
--- a/src/xml_dump.c
|
|
|
6cec19 |
+++ b/src/xml_dump.c
|
|
|
6cec19 |
@@ -53,6 +53,14 @@ gboolean cr_hascontrollchars(const unsigned char *str)
|
|
|
6cec19 |
return FALSE;
|
|
|
6cec19 |
}
|
|
|
6cec19 |
|
|
|
6cec19 |
+gchar *
|
|
|
6cec19 |
+cr_prepend_protocol(const gchar *url)
|
|
|
6cec19 |
+{
|
|
|
6cec19 |
+ if (url && *url == '/')
|
|
|
6cec19 |
+ return g_strconcat("file://", url, NULL);
|
|
|
6cec19 |
+ return g_strdup(url);
|
|
|
6cec19 |
+}
|
|
|
6cec19 |
+
|
|
|
6cec19 |
void
|
|
|
6cec19 |
cr_latin1_to_utf8(const unsigned char *in, unsigned char *out)
|
|
|
6cec19 |
{
|
|
|
6cec19 |
diff --git a/src/xml_dump.h b/src/xml_dump.h
|
|
|
6cec19 |
index 8bb11ed..4289fc2 100644
|
|
|
6cec19 |
--- a/src/xml_dump.h
|
|
|
6cec19 |
+++ b/src/xml_dump.h
|
|
|
6cec19 |
@@ -167,6 +167,14 @@ void cr_latin1_to_utf8(const unsigned char *in,
|
|
|
6cec19 |
*/
|
|
|
6cec19 |
gboolean cr_hascontrollchars(const unsigned char *str);
|
|
|
6cec19 |
|
|
|
6cec19 |
+/**
|
|
|
6cec19 |
+ * Prepend protocol if necessary
|
|
|
6cec19 |
+ *
|
|
|
6cec19 |
+ * @param url input url
|
|
|
6cec19 |
+ * @return output string, must be freed
|
|
|
6cec19 |
+ */
|
|
|
6cec19 |
+gchar *cr_prepend_protocol(const gchar *url);
|
|
|
6cec19 |
+
|
|
|
6cec19 |
/** @} */
|
|
|
6cec19 |
|
|
|
6cec19 |
#ifdef __cplusplus
|
|
|
6cec19 |
diff --git a/src/xml_dump_primary.c b/src/xml_dump_primary.c
|
|
|
6cec19 |
index 5695e06..1f0292b 100644
|
|
|
6cec19 |
--- a/src/xml_dump_primary.c
|
|
|
6cec19 |
+++ b/src/xml_dump_primary.c
|
|
|
6cec19 |
@@ -30,7 +30,6 @@
|
|
|
6cec19 |
|
|
|
6cec19 |
#define ERR_DOMAIN CREATEREPO_C_ERROR
|
|
|
6cec19 |
|
|
|
6cec19 |
-
|
|
|
6cec19 |
typedef enum {
|
|
|
6cec19 |
PCO_TYPE_PROVIDES,
|
|
|
6cec19 |
PCO_TYPE_CONFLICTS,
|
|
|
6cec19 |
@@ -279,9 +278,12 @@ cr_xml_dump_primary_base_items(xmlNodePtr root, cr_Package *package)
|
|
|
6cec19 |
|
|
|
6cec19 |
// Write location attribute base
|
|
|
6cec19 |
if (package->location_base && package->location_base[0] != '\0') {
|
|
|
6cec19 |
+ gchar *location_base_with_protocol = NULL;
|
|
|
6cec19 |
+ location_base_with_protocol = cr_prepend_protocol(package->location_base);
|
|
|
6cec19 |
cr_xmlNewProp(location,
|
|
|
6cec19 |
BAD_CAST "xml:base",
|
|
|
6cec19 |
- BAD_CAST package->location_base);
|
|
|
6cec19 |
+ BAD_CAST location_base_with_protocol);
|
|
|
6cec19 |
+ g_free(location_base_with_protocol);
|
|
|
6cec19 |
}
|
|
|
6cec19 |
|
|
|
6cec19 |
// Write location attribute href
|
|
|
6cec19 |
--
|
|
|
6cec19 |
libgit2 0.27.8
|
|
|
6cec19 |
|