[SWIFT3] URL parameters are not escaped
#6.400 aberto em 29 de ago. de 2017
Métricas do repositório
- Stars
- (12.701 stars)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
Description
swagger-codegen does not properly escape parametrized parts of a URL.
For example:
var path = "/recipient/{recipient}"
path = path.replacingOccurrences(of: "{recipient}", with: "\(recipient)", options: .literal, range: nil)
The "recipient" variable should be URLEscaped, but it isn't. Thus, if recipient contains spaces or illegal characters, the request fails. Depending on the source of the parameters, this could also lead to vulnerable code.
Swagger-codegen version
git commit id 18c57a65ed5def618be6495e86fd2d0c73f89882
Swagger declaration file content or url
n/a
Command line used for generation
not relevnt
Steps to reproduce
Use a swagger API that has parameters in the URL, for example: /article/{articleName}, then use "Hello World ../" as articleName
Related issues/PRs
n/a
Suggest a fix/enhancement
Properly url escape the passed parameters:
let param1 = param.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)