]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Torrent.String: Quote raw names
authorMatt Joiner <anacrolix@gmail.com>
Sat, 16 Feb 2019 07:33:14 +0000 (18:33 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 16 Feb 2019 07:33:14 +0000 (18:33 +1100)
t.go

diff --git a/t.go b/t.go
index 8af13dc2a16b5773782946635ecb7c473b4a2a82..452a717a5c4ce78d8d97dcb754dbd6aed383fc20 100644 (file)
--- a/t.go
+++ b/t.go
@@ -1,6 +1,7 @@
 package torrent
 
 import (
+       "strconv"
        "strings"
 
        "github.com/anacrolix/missinggo/pubsub"
@@ -221,9 +222,10 @@ func (t *Torrent) DownloadAll() {
 func (t *Torrent) String() string {
        s := t.name()
        if s == "" {
-               s = t.infoHash.HexString()
+               return t.infoHash.HexString()
+       } else {
+               return strconv.Quote(s)
        }
-       return s
 }
 
 func (t *Torrent) AddTrackers(announceList [][]string) {