Replace all occurrences of markup in notification.
fix_markup previously would only replace one occurrence of needle in the notification string. So we'd end up with some markup's making it through, if there was more than one of a particular kind. Introduces new function string_replace_all and calls it from fix_markup.
This commit is contained in:
		
							parent
							
								
									1b90d82972
								
							
						
					
					
						commit
						3beb9e42dc
					
				
							
								
								
									
										30
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								dunst.c
									
									
									
									
									
								
							| @ -874,23 +874,23 @@ char | ||||
|                 return NULL; | ||||
|         } | ||||
| 
 | ||||
|         str = string_replace(""", "\"", str); | ||||
|         str = string_replace("'", "'", str); | ||||
|         str = string_replace("&", "&", str); | ||||
|         str = string_replace("<", "<", str); | ||||
|         str = string_replace(">", ">", 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); | ||||
| 
 | ||||
|         /* remove tags */ | ||||
|         str = string_replace("<b>", "", str); | ||||
|         str = string_replace("</b>", "", str); | ||||
|         str = string_replace("<br>", " ", str); | ||||
|         str = string_replace("<br/>", " ", str); | ||||
|         str = string_replace("<br />", " ", str); | ||||
|         str = string_replace("<i>", "", str); | ||||
|         str = string_replace("</i>", "", str); | ||||
|         str = string_replace("<u>", "", str); | ||||
|         str = string_replace("</u>", "", str); | ||||
|         str = string_replace("</a>", "", str); | ||||
|         str = string_replace_all("<b>", "", str); | ||||
|         str = string_replace_all("</b>", "", str); | ||||
|         str = string_replace_all("<br>", " ", str); | ||||
|         str = string_replace_all("<br/>", " ", str); | ||||
|         str = string_replace_all("<br />", " ", str); | ||||
|         str = string_replace_all("<i>", "", str); | ||||
|         str = string_replace_all("</i>", "", str); | ||||
|         str = string_replace_all("<u>", "", str); | ||||
|         str = string_replace_all("</u>", "", str); | ||||
|         str = string_replace_all("</a>", "", str); | ||||
| 
 | ||||
|         start = strstr(str, "<a href"); | ||||
|         if (start != NULL) { | ||||
|  | ||||
							
								
								
									
										12
									
								
								utils.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								utils.c
									
									
									
									
									
								
							| @ -25,6 +25,18 @@ char *lskip(char *s) | ||||
|         return s; | ||||
| } | ||||
| 
 | ||||
| char *string_replace_all(const char *needle, const char *replacement, | ||||
|                          char *haystack) | ||||
| { | ||||
|         char *start; | ||||
|         start = strstr(haystack, needle); | ||||
|         while(start != NULL) { | ||||
|                 haystack = string_replace(needle, replacement, haystack); | ||||
|                 start = strstr(haystack, needle); | ||||
|         } | ||||
|         return haystack; | ||||
| } | ||||
| 
 | ||||
| char *string_replace(const char *needle, const char *replacement, | ||||
|                      char *haystack) | ||||
| { | ||||
|  | ||||
							
								
								
									
										4
									
								
								utils.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								utils.h
									
									
									
									
									
								
							| @ -4,6 +4,10 @@ | ||||
| char *rstrip(char *str); | ||||
| char *lskip(char *str); | ||||
| 
 | ||||
| /* replace all occurrences of needle with replacement in haystack */ | ||||
| char *string_replace_all(const char *needle, const char *replacement, | ||||
|                          char *haystack); | ||||
| 
 | ||||
| /* replace needle with replacement in haystack */ | ||||
| char *string_replace(const char *needle, const char *replacement, | ||||
|                      char *haystack); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Matthew Todd
						Matthew Todd