stage23-donation-button.py
TEXT FILE475 B · Public source code for developers, search crawlers and AI agents
1from html import escape
2import re
3
4def button(address):
5 if not re.fullmatch(r'[a-zA-Z0-9]{14,90}', address):
6 raise ValueError('invalid address characters')
7 return '<a href="bitcoin:' + escape(address, quote=True) + '">Donate Bitcoin</a>'
8
9if __name__ == '__main__':
10 assert button('tb1qsyntheticfixture').startswith('<a href="bitcoin:')
11 try: button('x" onclick="bad')
12 except ValueError: pass
13 else: raise AssertionError('unsafe input accepted')Read-only source · Select a line number to link directly · Raw download above
