File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 7
7
"fmt"
8
8
"strings"
9
9
"time"
10
+ "unicode/utf8"
10
11
11
12
"github.com/btcsuite/btcd/btcec/v2"
12
13
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
@@ -18,6 +19,12 @@ import (
18
19
"github.com/lightningnetwork/lnd/lnwire"
19
20
)
20
21
22
+ var (
23
+ // ErrInvalidUTF8Description is returned if the invoice description is
24
+ // not valid UTF-8.
25
+ ErrInvalidUTF8Description = errors .New ("description is not valid UTF-8" )
26
+ )
27
+
21
28
// DecodeOption is a type that can be used to supply functional options to the
22
29
// Decode function.
23
30
type DecodeOption func (* decodeOptions )
@@ -446,6 +453,10 @@ func parseDescription(data []byte) (*string, error) {
446
453
return nil , err
447
454
}
448
455
456
+ if ! utf8 .Valid (base256Data ) {
457
+ return nil , ErrInvalidUTF8Description
458
+ }
459
+
449
460
description := string (base256Data )
450
461
451
462
return & description , nil
You can’t perform that action at this time.
0 commit comments