aboutsummaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/html.c b/src/html.c
index 5a559e1..bd41611 100644
--- a/src/html.c
+++ b/src/html.c
@@ -86,6 +86,7 @@ static int url_extract_domain(const char *url, char *domain, int domain_len) {
typedef int (*PluginListCallback)(const char *name, const char *url, void *userdata);
static cJSON* plugin_list(char *plugin_filepath, const char *url, cJSON *downloaded_items, PluginListCallback callback, void *userdata) {
int result;
+ cJSON *json_root = NULL;
Buffer buffer;
buffer_init(&buffer);
@@ -129,7 +130,7 @@ static cJSON* plugin_list(char *plugin_filepath, const char *url, cJSON *downloa
goto err_cleanup;
}
- cJSON *json_root = cJSON_ParseWithLength(buffer.data, buffer.size);
+ json_root = cJSON_ParseWithLength(buffer.data, buffer.size);
if(!json_root) {
fprintf(stderr, "Failed to load plugin %s list output as json\n", basename(plugin_filepath));
goto err_cleanup;
@@ -138,7 +139,6 @@ static cJSON* plugin_list(char *plugin_filepath, const char *url, cJSON *downloa
if(!cJSON_IsArray(json_root)) {
fprintf(stderr, "Failed to load plugin %s list output as json\n", basename(plugin_filepath));
- cJSON_Delete(json_root);
goto err_cleanup;
}
@@ -156,13 +156,21 @@ static cJSON* plugin_list(char *plugin_filepath, const char *url, cJSON *downloa
char *name = name_json->valuestring;
string_replace(name, '/', '_');
name = strip(name);
+
+ if(name[0] == '\0' || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
+ fprintf(stderr, "Listing html chapter gave a chapter with an invalid name. The chapter name can't be empty, . or ..\n");
+ goto err_cleanup;
+ }
+
if(callback(name, url_json->valuestring, userdata) != 0)
- break;
+ goto err_cleanup;
}
return json_root;
err_cleanup:
+ if(json_root)
+ cJSON_Delete(json_root);
buffer_deinit(&buffer);
return NULL;
}
@@ -246,6 +254,11 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
return -1;
}
+ if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
+ fprintf(stderr, "Html name can't be . or ..\n");
+ return -1;
+ }
+
char domain[2086];
if(looks_like_mangadex_id(url)) {
strcpy(domain, "mangadex");