|
1 | 1 | # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved |
2 | 2 | import json |
3 | 3 | import random |
| 4 | +import re |
4 | 5 | from dataclasses import replace |
5 | 6 | from datetime import datetime, timezone |
6 | 7 | from math import floor |
|
28 | 29 | CounterpartyDataOptions, |
29 | 30 | ) |
30 | 31 | from uma.protocol.currency import Currency |
| 32 | +from uma.protocol.invoice import ( |
| 33 | + Invoice, |
| 34 | + InvoiceCounterpartyDataOptions, |
| 35 | + InvoiceCurrency, |
| 36 | +) |
31 | 37 | from uma.protocol.kyc_status import KycStatus |
32 | 38 | from uma.protocol.lnurlp_request import LnurlpRequest |
33 | 39 | from uma.protocol.lnurlp_response import LnurlComplianceResponse, LnurlpResponse |
|
45 | 51 | ) |
46 | 52 | from uma.protocol.post_tx_callback import PostTransactionCallback, UtxoWithAmount |
47 | 53 | from uma.protocol.pubkey_response import PubkeyResponse |
48 | | -from uma.protocol.invoice import ( |
49 | | - Invoice, |
50 | | - InvoiceCounterpartyDataOptions, |
51 | | - InvoiceCurrency, |
52 | | -) |
53 | 54 | from uma.public_key_cache import IPublicKeyCache |
54 | 55 | from uma.type_utils import none_throws |
55 | 56 | from uma.uma_invoice_creator import IUmaInvoiceCreator |
@@ -373,6 +374,9 @@ def parse_lnurlp_request(url: str) -> LnurlpRequest: |
373 | 374 | if len(paths) != 4 or paths[1] != ".well-known" or paths[2] != "lnurlp": |
374 | 375 | raise InvalidRequestException("Invalid request path.") |
375 | 376 |
|
| 377 | + if not re.match(r"^[\$a-zA-Z0-9@._\-\+]+$", paths[3]): |
| 378 | + raise InvalidRequestException("Invalid characters in receiver address.") |
| 379 | + |
376 | 380 | receiver_address = paths[3] + "@" + parsed_url.netloc |
377 | 381 | is_subject_to_travel_rule = ( |
378 | 382 | query.get("isSubjectToTravelRule", [""])[0].lower() == "true" |
|
0 commit comments