summaryrefslogtreecommitdiff
path: root/src/import
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-19 20:45:27 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-20 15:06:58 +0100
commita2e0337875addaf08225fbf9b231435ba12a88b5 (patch)
tree2d8db845ca71eef64593bc564931d9f21fc1fe9b /src/import
parent6c8f2e7d78b1fe280588dc91beae90cdf36fcd49 (diff)
util: make http url validity checks more generic, and move them to util.c
Diffstat (limited to 'src/import')
-rw-r--r--src/import/import-raw.c15
-rw-r--r--src/import/import-raw.h2
-rw-r--r--src/import/import.c2
3 files changed, 3 insertions, 16 deletions
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index 80fdbb7781..486157aa96 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -28,9 +28,9 @@
#include "utf8.h"
#include "curl-util.h"
#include "qcow2-util.h"
-#include "import-raw.h"
#include "strv.h"
#include "copy.h"
+#include "import-raw.h"
typedef struct RawImportFile RawImportFile;
@@ -904,7 +904,7 @@ int raw_import_pull(RawImport *import, const char *url, const char *local, bool
int r;
assert(import);
- assert(raw_url_is_valid(url));
+ assert(http_url_is_valid(url));
assert(!local || machine_name_is_valid(local));
if (hashmap_get(import->files, url))
@@ -949,14 +949,3 @@ int raw_import_pull(RawImport *import, const char *url, const char *local, bool
f = NULL;
return 0;
}
-
-bool raw_url_is_valid(const char *url) {
- if (isempty(url))
- return false;
-
- if (!startswith(url, "http://") &&
- !startswith(url, "https://"))
- return false;
-
- return ascii_is_valid(url);
-}
diff --git a/src/import/import-raw.h b/src/import/import-raw.h
index a423ec0187..17f7a1a8ee 100644
--- a/src/import/import-raw.h
+++ b/src/import/import-raw.h
@@ -33,5 +33,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(RawImport*, raw_import_unref);
int raw_import_pull(RawImport *import, const char *url, const char *local, bool force_local);
int raw_import_cancel(RawImport *import, const char *name);
-
-bool raw_url_is_valid(const char *url);
diff --git a/src/import/import.c b/src/import/import.c
index af8d0ec42b..9b10de5559 100644
--- a/src/import/import.c
+++ b/src/import/import.c
@@ -90,7 +90,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
int r;
url = argv[1];
- if (!raw_url_is_valid(url)) {
+ if (!http_url_is_valid(url)) {
log_error("URL '%s' is not valid.", url);
return -EINVAL;
}