[GH-ISSUE #492] [BUG] Empty Content for Key Value Encoding in View As menu #490

Open
opened 2026-03-03 19:19:13 +03:00 by kerem · 8 comments
Owner

Originally created by @NghiaTranUIT on GitHub (Apr 29, 2020).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/492

Originally assigned to: @NghiaTranUIT on GitHub.

Description

Proxyman is capable of rendering Base64 or Key-Value from Right Menu -> View as. However, there is a bug in the latest build that the data is empty

Screen Shot 2020-04-29 at 11 29 17

Acceptance Criteria

  • Able to see Base64 Decoder and Key-Value properly
Originally created by @NghiaTranUIT on GitHub (Apr 29, 2020). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/492 Originally assigned to: @NghiaTranUIT on GitHub. ### Description Proxyman is capable of rendering Base64 or Key-Value from Right Menu -> View as. However, there is a bug in the latest build that the data is empty <img width="1450" alt="Screen Shot 2020-04-29 at 11 29 17" src="https://user-images.githubusercontent.com/5878421/80560908-d79f3f80-8a0c-11ea-8c11-d4188c468731.png"> ### Acceptance Criteria - Able to see Base64 Decoder and Key-Value properly
Author
Owner

@NghiaTranUIT commented on GitHub (Apr 30, 2020):

Fixed: https://github.com/ProxymanApp/Proxyman/issues/484

<!-- gh-comment-id:621586308 --> @NghiaTranUIT commented on GitHub (Apr 30, 2020): Fixed: https://github.com/ProxymanApp/Proxyman/issues/484
Author
Owner

@crankygeek commented on GitHub (Aug 5, 2020):

@NghiaTranUIT Does this method use the OS' version of base64 util? If so, it sounds like it's pretty old and doesn't support newlines. I get "" as a result in my testing.

Any chance of bundling an updated version that handles it?

I was wondering if custom previewer tab would work for this, though it could be hard to do since you'd have to ID the encoded string within unencoded data.

<!-- gh-comment-id:669581525 --> @crankygeek commented on GitHub (Aug 5, 2020): @NghiaTranUIT Does this method use the OS' version of base64 util? If so, it sounds like it's pretty old and doesn't support newlines. I get "<Invalid Base64 String>" as a result in my testing. Any chance of bundling an updated version that handles it? I was wondering if custom previewer tab would work for this, though it could be hard to do since you'd have to ID the encoded string within unencoded data.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 6, 2020):

@crankygeek It's a standard func to decode base64String (utf8)

    public func decodeBase64() -> String? {
        guard let data = Data(base64Encoded: self) else { return nil }
        return String(data: data, encoding: .utf8)
    }
Screen Shot 2020-08-06 at 09 37 45

I tested and it works without any issue. Can you share with me a base64 string that cases the "" string? I would like to investigate

<!-- gh-comment-id:669649160 --> @NghiaTranUIT commented on GitHub (Aug 6, 2020): @crankygeek It's a standard func to decode base64String (utf8) ```swift public func decodeBase64() -> String? { guard let data = Data(base64Encoded: self) else { return nil } return String(data: data, encoding: .utf8) } ``` <img width="1232" alt="Screen Shot 2020-08-06 at 09 37 45" src="https://user-images.githubusercontent.com/5878421/89484423-ae8b0980-d7c8-11ea-95c5-e56c17e05697.png"> I tested and it works without any issue. Can you share with me a base64 string that cases the "" string? I would like to investigate
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 6, 2020):

You can validate from https://www.base64encode.org, to see if it decodes properly 😄

<!-- gh-comment-id:669649321 --> @NghiaTranUIT commented on GitHub (Aug 6, 2020): You can validate from https://www.base64encode.org, to see if it decodes properly 😄
Author
Owner

@crankygeek commented on GitHub (Aug 6, 2020):

Looks like I may be wrong about the newlines, but there is definitely something that the system base64 doesn't like. But here's an example string that I copied directly from the Raw Request which returns "" in Proxyman:

W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0=

Here's the output when trying to decode it using the system base64 (macOS 10.14.6):

{Argon / jack} ~ (20:39:14) : echo W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0= | base64 -D
Invalid character in input stream.

And here's the output using the base64 module included with python (Python 2.7.16):

{Argon / jack} ~ (20:39:40) : echo W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0= | python -m base64 -d
[{"properties":{"mp_lib":"swift","token":"85053b?=f24bba75239b16a601d9387e17","version":"3.0","$li?=b_version":"2.7.6","distinct_id":"cedb8c224e9e1f?=6949677a83d68032c4"},"event":"Integration"}]

And just to double check that my system base64 is working for simpler strings (source was encoded using the site you provided):

{Argon / jack} ~ (20:45:08) : echo VGhpcyBpcyBhIHNpbXBsZSBzdHJpbmcKVGhhdCBpcyBicm9rZW4gaW50bwpNdWx0aXBsZSBsaW5lcw== | base64 -D
This is a simple string
That is broken into
Multiple lines
<!-- gh-comment-id:669669352 --> @crankygeek commented on GitHub (Aug 6, 2020): Looks like I may be wrong about the newlines, but there is definitely something that the system base64 doesn't like. But here's an example string that I copied directly from the Raw Request which returns "<Invalid Base64 String>" in Proxyman: ``` W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0= ``` Here's the output when trying to decode it using the system `base64` (macOS 10.14.6): ``` {Argon / jack} ~ (20:39:14) : echo W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0= | base64 -D Invalid character in input stream. ``` And here's the output using the base64 module included with python (Python 2.7.16): ``` {Argon / jack} ~ (20:39:40) : echo W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0= | python -m base64 -d [{"properties":{"mp_lib":"swift","token":"85053b?=f24bba75239b16a601d9387e17","version":"3.0","$li?=b_version":"2.7.6","distinct_id":"cedb8c224e9e1f?=6949677a83d68032c4"},"event":"Integration"}] ``` And just to double check that my system base64 is working for simpler strings (source was encoded using the site you provided): ``` {Argon / jack} ~ (20:45:08) : echo VGhpcyBpcyBhIHNpbXBsZSBzdHJpbmcKVGhhdCBpcyBicm9rZW4gaW50bwpNdWx0aXBsZSBsaW5lcw== | base64 -D This is a simple string That is broken into Multiple lines ```
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 6, 2020):

It's an interesting base64 problem 💭

I tried and it works if decode with ignoreUnknownCharacters then converting to string by ASCII encoding. Otherwise, it won't work with normal decode and UTF8 String.

let text = "W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0="

guard let data = Data(base64Encoded: text, options: [.ignoreUnknownCharacters]) else {
    print("Could not decode")
    fatalError()
}

let value = String(data: data, encoding: .ascii)
print(value)

// Output:
"[{\"properties\":{\"mp_lib\":\"swift\",\"token\":\"85053bŠ=\0f24bba75239b16a601d9387e17\",\"version\":\"3.0\",\"$liŠ=\0b_version\":\"2.7.6\",\"distinct_id\":\"cedb8c224e9e1fŠ=\06949677a83d68032c4\"},\"event\":\"Integration\"}]"

I will improve the base64 decode string by adding this option and try to detect the text encoding 👍

<!-- gh-comment-id:669717850 --> @NghiaTranUIT commented on GitHub (Aug 6, 2020): It's an interesting base64 problem 💭 I tried and it works if decode with `ignoreUnknownCharacters` then converting to string by ASCII encoding. Otherwise, it won't work with normal decode and UTF8 String. ```swift let text = "W3sicHJvcGVydGllcyI6eyJtcF9saWIiOiJzd2lmdCIsInRva2VuIjoiODUwNTNi%0D%0AZjI0YmJhNzUyMzliMTZhNjAxZDkzODdlMTciLCJ2ZXJzaW9uIjoiMy4wIiwiJGxp%0D%0AYl92ZXJzaW9uIjoiMi43LjYiLCJkaXN0aW5jdF9pZCI6ImNlZGI4YzIyNGU5ZTFm%0D%0ANjk0OTY3N2E4M2Q2ODAzMmM0In0sImV2ZW50IjoiSW50ZWdyYXRpb24ifV0=" guard let data = Data(base64Encoded: text, options: [.ignoreUnknownCharacters]) else { print("Could not decode") fatalError() } let value = String(data: data, encoding: .ascii) print(value) // Output: "[{\"properties\":{\"mp_lib\":\"swift\",\"token\":\"85053bŠ=\0f24bba75239b16a601d9387e17\",\"version\":\"3.0\",\"$liŠ=\0b_version\":\"2.7.6\",\"distinct_id\":\"cedb8c224e9e1fŠ=\06949677a83d68032c4\"},\"event\":\"Integration\"}]" ``` I will improve the base64 decode string by adding this option and try to detect the text encoding 👍
Author
Owner

@crankygeek commented on GitHub (Aug 6, 2020):

Cool! Glad I could give you an interesting problem. 😄

Happy to look at a test build when you have one.

<!-- gh-comment-id:669722440 --> @crankygeek commented on GitHub (Aug 6, 2020): Cool! Glad I could give you an interesting problem. 😄 Happy to look at a test build when you have one.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 6, 2020):

Please check out this build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.3.0_Improve_Base64_Decoder.dmg

Screen Shot 2020-08-06 at 13 16 29

Changelog

  • Update how Proxyman attempts decoding base64 string (Work well in normal utf8 text and special cases (Auto detect the text encoding)
<!-- gh-comment-id:669746252 --> @NghiaTranUIT commented on GitHub (Aug 6, 2020): Please check out this build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.3.0_Improve_Base64_Decoder.dmg <img width="1719" alt="Screen Shot 2020-08-06 at 13 16 29" src="https://user-images.githubusercontent.com/5878421/89501365-69c59980-d7ed-11ea-9aa1-2ea3b48ee616.png"> ## Changelog - Update how Proxyman attempts decoding base64 string (Work well in normal utf8 text and special cases (Auto detect the text encoding)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#490
No description provided.