Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix malformed CBOR body #2502

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

lauzadis
Copy link
Contributor

Background

The body seems to have been inadvertently malformed in this commit.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lauzadis lauzadis requested a review from a team as a code owner January 17, 2025 21:54
@lauzadis lauzadis requested a review from sugmanue January 17, 2025 21:54
@rhernandez35
Copy link
Contributor

rhernandez35 commented Jan 17, 2025

The original payload is valid base64 and decodes into valid CBOR. The trailing = you added does not change the decoded payload – it's purely additional padding and is ignored. This demonstration:

    @Test
    public void decoding() {
        String s = "v2hkZWZhdWx0c79tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3Sf/3BkZWZhdWx0VGltZXN0YW1wwQBrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX6P4AAAGpkZWZhdWx0TWFwv/9rZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfoAAAAA//8";
        byte[] blob = Base64.getDecoder().decode(s.getBytes(StandardCharsets.UTF_8));
        byte[] blob2 = Base64.getDecoder().decode((s + "=").getBytes(StandardCharsets.UTF_8));
        assertArrayEquals(blob, blob2);
        System.out.println(blob.length + " " + blob2.length);
    }

passes and prints "347 347".

@rhernandez35
Copy link
Contributor

rhernandez35 commented Jan 17, 2025

Seems the JDK parser is happy to parse without padding, but the Kotlin SDK parser requires it. This is fine for compatibility purposes.

@sugmanue sugmanue merged commit 25890c4 into smithy-lang:main Jan 17, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants