mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	Merge pull request #1664 from return42/harden-get_engine_locales
[fix] harden get_engine_locale: handle UnknownLocaleError exceptions
This commit is contained in:
		
						commit
						649d1a144d
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
					@ -213,7 +213,13 @@ def get_engine_locale(searxng_locale, engine_locales, default=None):
 | 
				
			||||||
        # need to narrow language nor territory.
 | 
					        # need to narrow language nor territory.
 | 
				
			||||||
        return engine_locale
 | 
					        return engine_locale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    locale = babel.Locale.parse(searxng_locale, sep='-')
 | 
					    try:
 | 
				
			||||||
 | 
					        locale = babel.Locale.parse(searxng_locale, sep='-')
 | 
				
			||||||
 | 
					    except babel.core.UnknownLocaleError:
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            locale = babel.Locale.parse(searxng_locale.split('-')[1])
 | 
				
			||||||
 | 
					        except babel.core.UnknownLocaleError:
 | 
				
			||||||
 | 
					            return default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # SearXNG's selected locale is not supported by the engine ..
 | 
					    # SearXNG's selected locale is not supported by the engine ..
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue