-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: fix post policy escape bug, update conformance tests #924
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a bug reference for this?
if (c >= 128) { // is a unicode character | ||
escapedJson.append(String.format("\\u%04x", (int) c)); | ||
} else { | ||
switch (c) { | ||
case '\\': | ||
escapedJson.append("\\\\"); | ||
// The JsonObject/JsonArray operations above handle quote escapes, so leave any "/"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is forward slash meant here? Looks like it should be a backslash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be, will fix
StringBuilder escapedPolicy = new StringBuilder(); | ||
|
||
// Java automatically unescapes the unicode escapes in the conformance tests, so we need to | ||
// manually re-escape them | ||
for (char c : expectedPolicy.toCharArray()) { | ||
char[] expectedPolicyArray = expectedPolicy.toCharArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be reproducing the algorithm in the test. That risks copying bugs from one place to another, and verifying the buggy behavior. Can you make the expected output a literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they both happen to need to do the same thing (escaping certain characters). Sorry, I'm unsure what you mean by "make it a literal," can you elaborate?
@@ -93,7 +93,7 @@ | |||
<dependency> | |||
<groupId>com.google.cloud</groupId> | |||
<artifactId>google-cloud-conformance-tests</artifactId> | |||
<version>0.0.11</version> | |||
<version>0.1.1</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this verify the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in fact the failures caused by it is what brought the bug to my attention (#510)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge after fixing the typo
🤖 I have created a release \*beep\* \*boop\* --- ## [2.1.0](https://github.com/googleapis/java-storage/compare/v2.0.2...v2.1.0) (2021-08-24) ### Features * fix post policy escape bug, update conformance tests ([#924](https://github.com/googleapis/java-storage/issues/924)) ([d8329c3](https://github.com/googleapis/java-storage/commit/d8329c34fe19fd8c6bba5579aa3c55490c1d4e6f)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#976](https://github.com/googleapis/java-storage/issues/976)) ([5cac14d](https://github.com/googleapis/java-storage/commit/5cac14d7785ef3798c379d17cd44500958d9cc6a)) * update kms.version to v0.91.2 ([#977](https://github.com/googleapis/java-storage/issues/977)) ([1c60e6e](https://github.com/googleapis/java-storage/commit/1c60e6e6a34f662478043989b5b0bddea32cc5bf)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
V4 Post Policy had an issue where quotes in the json policy would get double escaped (
"
would became\\"
instead of\"
), this fixes that issue and updates the conformance tests to the latest version