Check magnet URI scheme

This commit is contained in:
Matt Joiner 2014-09-11 14:19:23 +10:00
parent 6c1c339ae4
commit daa3df5f7b
1 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,10 @@ func ParseMagnetURI(uri string) (m Magnet, err error) {
err = fmt.Errorf("error parsing uri: %s", err)
return
}
if u.Scheme != "magnet" {
err = fmt.Errorf("unexpected scheme: %q", u.Scheme)
return
}
xt := u.Query().Get("xt")
if !strings.HasPrefix(xt, xtPrefix) {
err = fmt.Errorf("bad xt parameter")