amazon-archives / aws-sdk-unity

ARCHIVED: The aws sdk for unity is now distributed as a part of aws sdk for dotnet:
https://github.com/aws/aws-sdk-net
Other
105 stars 43 forks source link

S3PostUploadSignedPolicy.addTokenToPolicy throws uncaught exception on Windows #117

Closed PLockhart closed 8 years ago

PLockhart commented 8 years ago

Thrown here

My policy is the following: {"expiration": "2016-07-22T14:37:19Z","conditions": [{"bucket": "testify-development"},["starts-with", "$key", "10\53\238\571.mp4"],{"acl": "public-read"},["eq", "$Content-Type", "video/mp4"]]}

The exception does not get thrown on OSX. Tested on a Windows 10 64 bit machine.

PLockhart commented 8 years ago

When I surround in a try catch I get the following callstack:

AWS Policy parsing exception ThirdParty.Json.LitJson.JsonException: Invalid character '5' in input string at ThirdParty.Json.LitJson.Lexer.NextToken () [0x0002c] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\Lexer.cs:884 at ThirdParty.Json.LitJson.JsonReader.ReadToken () [0x0000d] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonReader.cs:231 at ThirdParty.Json.LitJson.JsonReader.Read () [0x0029a] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonReader.cs:352 at ThirdParty.Json.LitJson.JsonMapper.ReadValue (ThirdParty.Json.LitJson.WrapperFactory factory, ThirdParty.Json.LitJson.JsonReader reader) [0x00000] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:490 at ThirdParty.Json.LitJson.JsonMapper.ReadValue (ThirdParty.Json.LitJson.WrapperFactory factory, ThirdParty.Json.LitJson.JsonReader reader) [0x000d9] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:527 at ThirdParty.Json.LitJson.JsonMapper.ReadValue (ThirdParty.Json.LitJson.WrapperFactory factory, ThirdParty.Json.LitJson.JsonReader reader) [0x000d9] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:527 at ThirdParty.Json.LitJson.JsonMapper.ReadValue (ThirdParty.Json.LitJson.WrapperFactory factory, ThirdParty.Json.LitJson.JsonReader reader) [0x00141] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:548 at ThirdParty.Json.LitJson.JsonMapper.ToWrapper (ThirdParty.Json.LitJson.WrapperFactory factory, ThirdParty.Json.LitJson.JsonReader reader) [0x00000] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:914 at ThirdParty.Json.LitJson.JsonMapper.ToObject (ThirdParty.Json.LitJson.JsonReader reader) [0x00000] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Core\ThirdParty\Json\JsonMapper.cs:874 at Amazon.S3.Util.S3PostUploadSignedPolicy.addTokenToPolicy (System.String policy, System.String token) [0x00000] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Services\S3\Custom\Util_bcl\S3PostUploadSignedPolicy.cs:87 at Amazon.S3.Util.S3PostUploadSignedPolicy.GetSignedPolicy (System.String policy, Amazon.Runtime.AWSCredentials credentials) [0x0001c] in E:\Github\user-testing-plugin-tool\Assets\AWSSDK\src\Services\S3\Custom\Util_bcl\S3PostUploadSignedPolicy.cs:62

karthiksaligrama commented 8 years ago

You JSON in policy is not correctly formed. You need to escape the characters.

{"expiration": "2016-07-22T14:37:19Z","conditions": [{"bucket": "testify-development"},["starts-with", "$key", "10\\53\\238\\571.mp4"],{"acl": "public-read"},["eq", "$Content-Type", "video/mp4"]]}
PLockhart commented 8 years ago

Ok thanks, I will check this out in the morning. Why might it work on platforms other than windows though? I don't see any platform dependent code in the json parser.

jdmiranda commented 8 years ago

windows and linux environments don't escape all characters the same. On Mon, Jan 18, 2016 at 13:19 Peter Lockhart notifications@github.com wrote:

Ok thanks, I will check this out in the morning. Why might it work on platforms other than windows though? I don't see any platform dependent code in the json parser.

— Reply to this email directly or view it on GitHub https://github.com/aws/aws-sdk-unity/issues/117#issuecomment-172627338.

PLockhart commented 8 years ago

Thanks