1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

script: add option script.scripts.url_force_https (closes #253)

This commit is contained in:
Sébastien Helleu
2014-11-15 18:28:34 +01:00
parent bc3c81ee4f
commit 786999b4a3
25 changed files with 4477 additions and 1457 deletions
+37
View File
@@ -95,6 +95,43 @@ script_language_search_by_extension (const char *extension)
return -1;
}
/*
* Builds download URL (to use with hook_process or hook_process_hashtable).
*
* If the option script.scripts.url_force_https is enabled, the protocol is
* forced to HTTPS (if URL starts with "http://").
*
* Note: result must be freed after use.
*/
char *
script_build_download_url (const char *url)
{
char *result;
int length;
if (!url || !url[0])
return NULL;
/* length of url + "url:" + 1 (for httpS) */
length = 4 + 1 + strlen (url) + 1;
result = malloc (length);
if (!result)
return NULL;
if (weechat_config_boolean (script_config_scripts_url_force_https)
&& (weechat_strncasecmp (url, "http://", 7) == 0))
{
snprintf (result, length, "url:https://%s", url + 7);
}
else
{
snprintf (result, length, "url:%s", url);
}
return result;
}
/*
* Gets loaded plugins (in array of integers) and scripts (in hashtable).
*/