Skip to content

Commit

Permalink
Escape quotes in curl command
Browse files Browse the repository at this point in the history
JSON will have quotes which need to be escaped before being run on the
command line.
  • Loading branch information
johngibb committed Oct 15, 2014
1 parent 9430470 commit 0193659
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/Alamofire.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,9 @@ extension Request: DebugPrintable {
}

if let HTTPBody = request.HTTPBody {
components.append("-d \"\(NSString(data: HTTPBody, encoding: NSUTF8StringEncoding))\"")
let escapedBody = NSString(data: HTTPBody, encoding: NSUTF8StringEncoding)
.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
components.append("-d \"\(escapedBody)\"")
}

components.append("\"\(URL.absoluteString!)\"")
Expand Down

0 comments on commit 0193659

Please sign in to comment.