mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-03 19:17:07 -05:00 
			
		
		
		
	[fix] server side error: escape backslashes in the query highlight_content
Any backslash escapes in the replacement are processed [1], backslashes should be escaped [2]. [1] https://docs.python.org/3/library/re.html#re.sub [2] https://docs.python.org/3/library/re.html#re.escape closes: - https://github.com/searxng/searxng/issues/2256 - https://github.com/searxng/searxng/issues/2250
This commit is contained in:
		
							parent
							
								
									3e9cddc606
								
							
						
					
					
						commit
						fbb0e9d275
					
				@ -174,7 +174,9 @@ def highlight_content(content, query):
 | 
			
		||||
            queries.extend(re.findall(regex_highlight_cjk(qs), content, flags=re.I | re.U))
 | 
			
		||||
    if len(queries) > 0:
 | 
			
		||||
        for q in set(queries):
 | 
			
		||||
            content = re.sub(regex_highlight_cjk(q), f'<span class="highlight">{q}</span>', content)
 | 
			
		||||
            content = re.sub(
 | 
			
		||||
                regex_highlight_cjk(q), f'<span class="highlight">{q}</span>'.replace('\\', r'\\'), content
 | 
			
		||||
            )
 | 
			
		||||
    return content
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user