From 9b0a1ccc699966f857c66d2f3f263f65e6ca964e Mon Sep 17 00:00:00 2001 From: Christian Schwede Date: Tue, 28 Jun 2016 15:34:52 +0200 Subject: [PATCH] Fix inline tempurl/formpost signature examples The inline examples contain double backslashes, and this creates invalid signatures. This bugged me a second time now, so let's fix that and make it fool proof so that I don't need to check the proxy server logs another time for the same reason. Changed the docstring to raw docstring to render the backslashes correctly both in Python and in the restructured text, according to http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism Change-Id: I77e12cfd12ad998346dd42f7245b9d27124a0a97 --- swift/common/middleware/formpost.py | 4 ++-- swift/common/middleware/tempurl.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/swift/common/middleware/formpost.py b/swift/common/middleware/formpost.py index 96024bd5d2..8ba5ddc51e 100644 --- a/swift/common/middleware/formpost.py +++ b/swift/common/middleware/formpost.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" +r""" FormPost Middleware Translates a browser form post into a regular Swift object PUT. @@ -86,7 +86,7 @@ sample code for computing the signature:: max_file_count = 10 expires = int(time() + 600) key = 'mykey' - hmac_body = '%s\\n%s\\n%s\\n%s\\n%s' % (path, redirect, + hmac_body = '%s\n%s\n%s\n%s\n%s' % (path, redirect, max_file_size, max_file_count, expires) signature = hmac.new(key, hmac_body, sha1).hexdigest() diff --git a/swift/common/middleware/tempurl.py b/swift/common/middleware/tempurl.py index cf140edcba..0f13fd8131 100644 --- a/swift/common/middleware/tempurl.py +++ b/swift/common/middleware/tempurl.py @@ -28,7 +28,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" +r""" TempURL Middleware Allows the creation of URLs to provide temporary access to objects. @@ -69,7 +69,7 @@ seconds on ``/v1/AUTH_account/container/object``:: expires = int(time() + 60) path = '/v1/AUTH_account/container/object' key = 'mykey' - hmac_body = '%s\\n%s\\n%s' % (method, expires, path) + hmac_body = '%s\n%s\n%s' % (method, expires, path) sig = hmac.new(key, hmac_body, sha1).hexdigest() Be certain to use the full path, from the ``/v1/`` onward.