diff --git a/notification.c b/notification.c index b0b12a4..5be57fd 100644 --- a/notification.c +++ b/notification.c @@ -191,25 +191,8 @@ char *notification_strip_markup(char *str) return NULL; } - str = string_replace_all(""", "\"", str); - str = string_replace_all("'", "'", str); - str = string_replace_all("&", "&", str); - str = string_replace_all("<", "<", str); - str = string_replace_all(">", ">", str); - - /* remove tags */ - str = string_replace_all("", "", str); - str = string_replace_all("", "", str); - str = string_replace_all("
", " ", str); - str = string_replace_all("
", " ", str); - str = string_replace_all("
", " ", str); - str = string_replace_all("", "", str); - str = string_replace_all("", "", str); - str = string_replace_all("", "", str); - str = string_replace_all("", "", str); - str = string_replace_all("", "", str); - - while ((start = strstr(str, ""); if (end != NULL) { replace_buf = strndup(start, end - start + 1); @@ -220,16 +203,13 @@ char *notification_strip_markup(char *str) } } - while ((start = strstr(str, ""); - if (end != NULL) { - replace_buf = strndup(start, end - start + 2); - str = string_replace(replace_buf, "", str); - free(replace_buf); - } else { - break; - } - } + /* unquote the remainder */ + str = string_replace_all(""", "\"", str); + str = string_replace_all("'", "'", str); + str = string_replace_all("&", "&", str); + str = string_replace_all("<", "<", str); + str = string_replace_all(">", ">", str); + return str; } @@ -270,19 +250,25 @@ char *notification_replace_format(const char *needle, const char *replacement, tmp = notification_quote_markup(tmp); ret = string_replace_all(needle, tmp, haystack); free(tmp); - } else if (!allow_markup) { + } else { tmp = strdup(replacement); - if (!settings.ignore_newline) { + if (settings.ignore_newline) { + tmp = string_replace_all("
", " ", tmp); + tmp = string_replace_all("
", " ", tmp); + tmp = string_replace_all("
", " ", tmp); + } else { tmp = string_replace_all("
", "\n", tmp); tmp = string_replace_all("
", "\n", tmp); tmp = string_replace_all("
", "\n", tmp); } - tmp = notification_strip_markup(tmp); - tmp = notification_quote_markup(tmp); + + if (!allow_markup) { + tmp = notification_strip_markup(tmp); + tmp = notification_quote_markup(tmp); + } + ret = string_replace_all(needle, tmp, haystack); free(tmp); - } else { - ret = string_replace_all(needle, replacement, haystack); } return ret; @@ -320,7 +306,7 @@ char *notification_extract_markup_urls(char **str_ptr) { } free(replace_buf); } else { - break; + break; } } *str_ptr = str;