Skip to content

Commit

Permalink
Fix ID isn't unescaped when putting meta into context
Browse files Browse the repository at this point in the history
  • Loading branch information
doingodswork committed Jan 16, 2021
1 parent 4a3ca2b commit c21b93a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions middleware.go
Expand Up @@ -2,6 +2,7 @@ package stremio

import (
"fmt"
"net/url"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -308,6 +309,12 @@ func putMetaInContext(c *fiber.Ctx, metaClient MetaFetcher, logger *zap.Logger)
// type and id can never be empty, because that's been checked by a previous middleware
t := c.Params("type", "")
id := c.Params("id", "")
id, err = url.PathUnescape(id)
if err != nil {
logger.Error("ID in URL parameters couldn't be unescaped", zap.String("id", id))
return
}

switch t {
case "movie":
meta, err = metaClient.GetMovie(c.Context(), id)
Expand Down Expand Up @@ -337,6 +344,7 @@ func putMetaInContext(c *fiber.Ctx, metaClient MetaFetcher, logger *zap.Logger)
return
}
}

logger.Debug("Got meta from cinemata client", zap.String("meta", fmt.Sprintf("%+v", meta)))
c.Locals("meta", meta)
}

0 comments on commit c21b93a

Please sign in to comment.