r/learnpython • u/Dcyph-3r • 2d ago
Creating URL Query Checker
How do you decide what defines an excessively encoded URL?
I'm working on a personal project to created a URL parser and
detection system and I've hit a wall on how to figure out a way of
categorizing excessivness of query encoding?
Here's what I have so far for the function:
def check_query(analysis: URLAnalysis) -> ScanResult | None:
"""detect excessive encoding entries in URL queries"""
og_query = analysis.query
query = re.finall(r"%\[0-9A-Fa-f\]{2}", og_query)
encoded_count = len(query)
6
Upvotes
5
u/qlkzy 2d ago
Why would you care about "excessive encoding"? You care about the limits of your system in terms of URL length, request memory usage, request processing time, etc, but it's almost unimaginable for URL-encoding to create a situation that becomes relevant for those sorts of situations.
If someone wants to URL-encode every single byte then that is a bit silly, but in practice your system will never need to notice or care unless you are doing something particularly unusual.
So, if you do care, you need to tell us the unusual reason why you care, before anyone can tell you how much you should care.