mirror of
				https://git.sr.ht/~tsileo/microblog.pub
				synced 2025-06-05 21:59:23 +02:00 
			
		
		
		
	Remove surrounding whitespace before processing query
Ran into this issue twice quite by accident with fat-fingering copy/paste on my phone. If there is any whitespace in front of or trailing after the lookup query, it returns an "Unexpected error". Stripping the string is the quick and dirty way to clean it. I hate modifying the same function argument name in place like that, but it is valid Python. If you want me to assign it to a separate variable and replace all the references of "query", let me know. Thanks!
This commit is contained in:
		
				
					committed by
					
						 Thomas Sileo
						Thomas Sileo
					
				
			
			
				
	
			
			
			
						parent
						
							6d933863d2
						
					
				
				
					commit
					0ef2f1f89d
				
			| @@ -10,6 +10,7 @@ from app.source import _MENTION_REGEX | ||||
|  | ||||
|  | ||||
| async def lookup(db_session: AsyncSession, query: str) -> Actor | RemoteObject: | ||||
|     query = query.strip() | ||||
|     if query.startswith("@") or _MENTION_REGEX.match("@" + query): | ||||
|         query = await webfinger.get_actor_url(query)  # type: ignore  # None check below | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user