Skip to content

Commit

Permalink
Sanitize user names when parsing lnurlp urls
Browse files Browse the repository at this point in the history
  • Loading branch information
jklein24 committed Sep 21, 2024
1 parent 7c8d698 commit 3431b16
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion uma/uma.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math/big"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -313,7 +314,12 @@ func ParseLnurlpRequestWithReceiverDomain(url url.URL, receiverDomain string) (*
if len(pathParts) != 4 || pathParts[1] != ".well-known" || pathParts[2] != "lnurlp" {
return nil, errors.New("invalid uma request path")
}
receiverAddress := pathParts[3] + "@" + receiverDomain
username := pathParts[3]
var validUsernameRegex = regexp.MustCompile(`^[$a-zA-Z0-9._\-+]+$`)
if !validUsernameRegex.MatchString(username) {
return nil, errors.New("invalid uma username")
}
receiverAddress := username + "@" + receiverDomain

nilIfEmpty := func(s string) *string {
if s == "" {
Expand Down

0 comments on commit 3431b16

Please sign in to comment.