Fix: Robust base64 and string fallback for body decoding (#73) - #84
Open
furkancingoz wants to merge 1 commit into
Open
Fix: Robust base64 and string fallback for body decoding (#73)#84furkancingoz wants to merge 1 commit into
furkancingoz wants to merge 1 commit into
Conversation
…chars Fixed an issue (Trendyol#73) where would crash with a error when was not valid base64 (e.g. when raw JSON strings containing Arabic characters were sent instead of a base64 encoded string, or when the base64 string had missing padding). Implemented a custom in to handle standard Base64, padded Base64, and raw string fallbacks gracefully.
Collaborator
|
hello, root problem is not inside mocking star. So no need this pr more info: #73 (comment) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #73
When the client passes a raw JSON string instead of a base64 encoded string (or a base64 string with missing padding),
JSONDecodercurrently crashes withEncountered Data is not valid Base64. This caused Mockingstar to fail at mocking requests that had Arabic characters in the body, as the payload wasn't valid strict base64.This PR adds a custom
init(from decoder: Decoder)toMockServerRequestModelwhich gracefully falls back:Also includes unit tests to ensure no regressions.