1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

script: fix removal of script in system directory while trying to install a script (issue #2019)

This commit is contained in:
Sébastien Helleu
2023-09-22 22:51:44 +02:00
parent 15214f9538
commit 6c36836182
11 changed files with 32 additions and 26 deletions
+1
View File
@@ -25,6 +25,7 @@ Bug fixes::
* irc: fix title of private buffers wrongly set to own address when capability echo-message is enabled (issue #2016)
* irc: fix autojoin of channels when private buffers are opened (issue #2012)
* irc: fix string comparison when CASEMAPPING is set to "ascii"
* script: fix removal of script in system directory while trying to install a script (issue #2019)
* script: fix autoload of multiple scripts at once with `/script autoload` (issue #2018)
* script: fix crash when a `/script` command triggers another `/script` command (issue #923)
* xfer: fix memory leak on plugin unload
+1 -1
View File
@@ -876,7 +876,7 @@ weechat_guile_command_cb (const void *pointer, void *data,
{
/* load guile script */
path_script = plugin_script_search_path (weechat_guile_plugin,
ptr_name);
ptr_name, 1);
weechat_guile_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -657,7 +657,7 @@ weechat_js_command_cb (const void *pointer, void *data,
{
/* load javascript script */
path_script = plugin_script_search_path (weechat_js_plugin,
ptr_name);
ptr_name, 1);
weechat_js_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -975,7 +975,7 @@ weechat_lua_command_cb (const void *pointer, void *data,
{
/* load lua script */
path_script = plugin_script_search_path (weechat_lua_plugin,
ptr_name);
ptr_name, 1);
weechat_lua_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -963,7 +963,7 @@ weechat_perl_command_cb (const void *pointer, void *data,
{
/* load perl script */
path_script = plugin_script_search_path (weechat_perl_plugin,
ptr_name);
ptr_name, 1);
weechat_perl_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -977,7 +977,7 @@ weechat_php_command_cb (const void *pointer, void *data,
{
/* load PHP script */
path_script = plugin_script_search_path (weechat_php_plugin,
ptr_name);
ptr_name, 1);
weechat_php_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+21 -17
View File
@@ -536,7 +536,8 @@ plugin_script_search_by_full_name (struct t_plugin_script *scripts,
char *
plugin_script_search_path (struct t_weechat_plugin *weechat_plugin,
const char *filename)
const char *filename,
int search_system_dir)
{
char *final_name, *weechat_data_dir, *dir_system;
int length;
@@ -601,28 +602,31 @@ plugin_script_search_path (struct t_weechat_plugin *weechat_plugin,
free (weechat_data_dir);
}
/* try WeeChat system dir */
dir_system = weechat_info_get ("weechat_sharedir", "");
if (dir_system)
if (search_system_dir)
{
length = strlen (dir_system) + strlen (weechat_plugin->name) +
strlen (filename) + 16;
final_name = malloc (length);
if (final_name)
/* try WeeChat system dir */
dir_system = weechat_info_get ("weechat_sharedir", "");
if (dir_system)
{
snprintf (final_name,length,
"%s/%s/%s", dir_system, weechat_plugin->name, filename);
if ((stat (final_name, &st) == 0) && (st.st_size > 0))
length = strlen (dir_system) + strlen (weechat_plugin->name) +
strlen (filename) + 16;
final_name = malloc (length);
if (final_name)
{
free (dir_system);
return final_name;
snprintf (final_name,length,
"%s/%s/%s", dir_system, weechat_plugin->name, filename);
if ((stat (final_name, &st) == 0) && (st.st_size > 0))
{
free (dir_system);
return final_name;
}
free (final_name);
}
free (final_name);
free (dir_system);
}
free (dir_system);
}
return strdup (filename);
return NULL;
}
/*
@@ -1146,7 +1150,7 @@ plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin,
i = 0;
while (i < 2)
{
path_script = plugin_script_search_path (weechat_plugin, name);
path_script = plugin_script_search_path (weechat_plugin, name, 0);
/*
* script not found? (if path_script == name, that means the function
* above did not find the script)
+2 -1
View File
@@ -135,7 +135,8 @@ extern void plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin,
extern struct t_plugin_script *plugin_script_search (struct t_plugin_script *scripts,
const char *name);
extern char *plugin_script_search_path (struct t_weechat_plugin *weechat_plugin,
const char *filename);
const char *filename,
int search_system_dir);
extern struct t_plugin_script *plugin_script_alloc (const char *filename,
const char *name,
const char *author,
+1 -1
View File
@@ -1201,7 +1201,7 @@ weechat_python_command_cb (const void *pointer, void *data,
{
/* load python script */
path_script = plugin_script_search_path (weechat_python_plugin,
ptr_name);
ptr_name, 1);
weechat_python_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -1003,7 +1003,7 @@ weechat_ruby_command_cb (const void *pointer, void *data,
{
/* load ruby script */
path_script = plugin_script_search_path (weechat_ruby_plugin,
ptr_name);
ptr_name, 1);
weechat_ruby_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)
+1 -1
View File
@@ -658,7 +658,7 @@ weechat_tcl_command_cb (const void *pointer, void *data,
{
/* load tcl script */
path_script = plugin_script_search_path (weechat_tcl_plugin,
ptr_name);
ptr_name, 1);
weechat_tcl_load ((path_script) ? path_script : ptr_name,
NULL);
if (path_script)