Move url prefix removal to open_browser
This way, it also applies to middle clicks. Incidentally, it seems this fixed a crash when opening <a href> urls.
This commit is contained in:
parent
e04bfe0a58
commit
c8e6f317ab
28
src/menu.c
28
src/menu.c
@ -94,11 +94,16 @@ char *extract_urls(const char *to_match)
|
|||||||
* Open url in browser.
|
* Open url in browser.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void open_browser(const char *url)
|
void open_browser(const char *in) {
|
||||||
{
|
// remove prefix and test url
|
||||||
|
char *url = extract_urls(in);
|
||||||
|
if (!url)
|
||||||
|
return;
|
||||||
|
|
||||||
int browser_pid1 = fork();
|
int browser_pid1 = fork();
|
||||||
|
|
||||||
if (browser_pid1) {
|
if (browser_pid1) {
|
||||||
|
g_free(url);
|
||||||
int status;
|
int status;
|
||||||
waitpid(browser_pid1, &status, 0);
|
waitpid(browser_pid1, &status, 0);
|
||||||
} else {
|
} else {
|
||||||
@ -164,23 +169,10 @@ void dispatch_menu_result(const char *input)
|
|||||||
{
|
{
|
||||||
char *in = g_strdup(input);
|
char *in = g_strdup(input);
|
||||||
g_strstrip(in);
|
g_strstrip(in);
|
||||||
switch (in[0]) {
|
if (in[0] == '#') {
|
||||||
case '#':
|
|
||||||
invoke_action(in + 1);
|
invoke_action(in + 1);
|
||||||
break;
|
} else {
|
||||||
case '[': // named url. skip name and continue
|
open_browser(in);
|
||||||
in = strchr(in, ']');
|
|
||||||
if (in == NULL)
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{ // test and open url
|
|
||||||
char *maybe_url = extract_urls(in);
|
|
||||||
if (maybe_url) {
|
|
||||||
open_browser(maybe_url);
|
|
||||||
g_free(maybe_url);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g_free(in);
|
g_free(in);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#define DUNST_MENU_H
|
#define DUNST_MENU_H
|
||||||
|
|
||||||
char *extract_urls(const char *to_match);
|
char *extract_urls(const char *to_match);
|
||||||
void open_browser(const char *url);
|
void open_browser(const char *in);
|
||||||
void invoke_action(const char *action);
|
void invoke_action(const char *action);
|
||||||
void regex_teardown(void);
|
void regex_teardown(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user