-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apparently Data.withContiguousStorageIfAvailable() doesn't work
Use withUnsafeBytes instead. Added a test to ensure we get the same signature from string, data and byteBuffer. Also added '+' as a character to be percent encoded.
- Loading branch information
1 parent
28f9603
commit 8cd6b1a
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,8 @@ public class AWSSigner { | |
case .string(let string): | ||
hash = sha256(string) | ||
case .data(let data): | ||
hash = data.withContiguousStorageIfAvailable { bytes in | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
adam-fowler
Author
Owner
|
||
return sha256(bytes) | ||
hash = data.withUnsafeBytes { bytes in | ||
return sha256(bytes.bindMemory(to: UInt8.self)) | ||
} | ||
case .byteBuffer(let byteBuffer): | ||
let byteBufferView = byteBuffer.readableBytesView | ||
|
@@ -220,5 +220,5 @@ public class AWSSigner { | |
return formatter.string(from: date) | ||
} | ||
|
||
static let queryAllowedCharacters = CharacterSet(charactersIn:"/;").inverted | ||
static let queryAllowedCharacters = CharacterSet(charactersIn:"/;+").inverted | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can someone explain why this is necessary / why withContiguousStorageIfAvailable fails?