diff --git a/dunst.c b/dunst.c
index facee4b..32557dd 100644
--- a/dunst.c
+++ b/dunst.c
@@ -334,90 +334,47 @@ dunst_printf(const char *fmt, ...) {
char
*fix_markup(char *str) {
- char *tmpString, *strpos, *tmppos;
char *replace_buf, *start, *end;
if(str == NULL) {
return NULL;
}
- /* tmpString can never be bigger than str */
- tmpString = (char *) calloc(strlen(str), sizeof(char) + 1);
- memset(tmpString, '\0', strlen(tmpString) * sizeof(char) + 1);
- tmppos = tmpString;
- strpos = str;
+ str = string_replace(""", "\"", str);
+ str = string_replace("'", "'", str);
+ str = string_replace("&", "&", str);
+ str = string_replace("<", "<", str);
+ str = string_replace(">", ">", str);
- while(*strpos != '\0') {
- if(*strpos != '&') {
- /* not the beginning of an xml-escape */
- *tmppos = *strpos;
- strpos++;
- tmppos++;
- continue;
- }
- else if(!strncmp(strpos, """, strlen("""))) {
- *tmppos = '"';
- tmppos++;
- strpos += strlen(""");
- }
- else if(!strncmp(strpos, "'", strlen("apos;"))) {
- *tmppos = '\'';
- tmppos++;
- strpos += strlen("'");
- }
- else if(!strncmp(strpos, "&", strlen("amp;"))) {
- *tmppos = '&';
- tmppos++;
- strpos += strlen("&");
- }
- else if(!strncmp(strpos, "<", strlen("lt;"))) {
- *tmppos = '<';
- tmppos++;
- strpos += strlen("<");
- }
- else if(!strncmp(strpos, ">", strlen("gt;"))) {
- *tmppos = '>';
- tmppos++;
- strpos += strlen(">");
- }
- else {
- *tmppos = *strpos;
- strpos++;
- tmppos++;
- }
- }
-
- free(str);
-
- tmpString = string_replace("\n", " ", tmpString);
+ str = string_replace("\n", " ", str);
/* remove tags */
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
- tmpString = string_replace("", "", tmpString);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
+ str = string_replace("", "", str);
- start = strstr(tmpString, "");
+ end = strstr(str, ">");
if(end != NULL) {
replace_buf = strndup(start, end-start+1);
- tmpString = string_replace(replace_buf, "", tmpString);
+ str = string_replace(replace_buf, "", str);
free(replace_buf);
}
}
- start = strstr(tmpString, "
");
+ end = strstr(str, "/>");
if(end != NULL) {
replace_buf = strndup(start, end-start+2);
- tmpString = string_replace(replace_buf, "", tmpString);
+ str = string_replace(replace_buf, "", str);
free(replace_buf);
}
}
- return tmpString;
+ return str;
}