Fix URL matching regex
The URL matching regex as currently used by dust is too liberal, and will just match about anything. Some examples: "establishing connection..." => connection... "setting volume to [50%]" => 50%] The following expression is an adapted copy of urxvt's URL matcher.
This commit is contained in:
		
							parent
							
								
									2638178e5a
								
							
						
					
					
						commit
						2023623b16
					
				
							
								
								
									
										4
									
								
								menu.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								menu.c
									
									
									
									
									
								
							| @ -28,7 +28,9 @@ char *extract_urls(const char *to_match) | |||||||
| 
 | 
 | ||||||
|         if (!is_initialized) { |         if (!is_initialized) { | ||||||
|                 char *regex = |                 char *regex = | ||||||
|                     "((http[s]?|ftp[s]?)(://))?(www\\.)?[[:alnum:]._-]+\\.[^[:space:].\"<>]{2,}"; |                     "\\b(https?://|ftps?://|news://|mailto:|file://|www\\.)" | ||||||
|  |                     "[[:alnum:]\\-\\@;/?:&=%$.+!*\x27,~#]*" | ||||||
|  |                     "(\\([[:alnum:]\\-\\@;/?:&=%$.+!*\x27,~#]*\\)|[[:alnum:]\\-\\@;/?:&=%$+*~])+"; | ||||||
|                 int ret = regcomp(&cregex, regex, REG_EXTENDED | REG_ICASE); |                 int ret = regcomp(&cregex, regex, REG_EXTENDED | REG_ICASE); | ||||||
|                 if (ret != 0) { |                 if (ret != 0) { | ||||||
|                         printf("failed to compile regex\n"); |                         printf("failed to compile regex\n"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Yuri D'Elia
						Yuri D'Elia