~tsileo/microblog.pub-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Remove surrounding whitespace before processing query

Details
Message ID
<20220830235031.34945-1-josh@jodh.us>
DKIM signature
pass
Download raw message
Patch: +1 -0
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!


---
 app/lookup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/lookup.py b/app/lookup.py
index 7e15404..7be3cff 100644
--- a/app/lookup.py
+++ b/app/lookup.py
@@ -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

-- 
2.34.1
Details
Message ID
<cc8bfbd4-62a9-4125-8350-d2141cb211b4@www.fastmail.com>
In-Reply-To
<20220830235031.34945-1-josh@jodh.us> (view parent)
DKIM signature
pass
Download raw message
In this case, I think this is good enough. Stripping the input makes sense.

Thanks!
Reply to thread Export thread (mbox)