mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-02-01 04:21:02 +00:00
Add files via upload (#150)
This commit is contained in:
37
webapp.py
37
webapp.py
@@ -102,10 +102,39 @@ def ducky_main(request):
|
|||||||
|
|
||||||
return(response)
|
return(response)
|
||||||
|
|
||||||
def cleanup_text(buffer):
|
_hexdig = '0123456789ABCDEFabcdef'
|
||||||
return_buffer = buffer.replace('+', ' ').replace('%0D%0A', '\n') + '\n'
|
_hextobyte = None
|
||||||
#print(return_buffer)
|
|
||||||
return(return_buffer)
|
def cleanup_text(string):
|
||||||
|
"""unquote('abc%20def') -> b'abc def'."""
|
||||||
|
global _hextobyte
|
||||||
|
|
||||||
|
if not string:
|
||||||
|
return b''
|
||||||
|
|
||||||
|
if isinstance(string, str):
|
||||||
|
string = string.encode('utf-8')
|
||||||
|
|
||||||
|
bits = string.split(b'%')
|
||||||
|
if len(bits) == 1:
|
||||||
|
return string
|
||||||
|
|
||||||
|
res = [bits[0]]
|
||||||
|
append = res.append
|
||||||
|
|
||||||
|
if _hextobyte is None:
|
||||||
|
_hextobyte = {(a + b).encode(): bytes([int(a + b, 16)])
|
||||||
|
for a in _hexdig for b in _hexdig}
|
||||||
|
|
||||||
|
for item in bits[1:]:
|
||||||
|
try:
|
||||||
|
append(_hextobyte[item[:2]])
|
||||||
|
append(item[2:])
|
||||||
|
except KeyError:
|
||||||
|
append(b'%')
|
||||||
|
append(item)
|
||||||
|
|
||||||
|
return b''.join(res).decode().replace('+',' ')
|
||||||
|
|
||||||
web_app = WSGIApp()
|
web_app = WSGIApp()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user