pawitp / protobuf-decoder

JavaScript-based web UI to decode ad-hoc Protobuf data
https://protobuf-decoder.netlify.app/
MIT License
372 stars 90 forks source link

This tool doesn't decode url encoded ProtoBuf messages #75

Open adibalcan opened 9 months ago

adibalcan commented 9 months ago

I can't decode the following message with this tool:

!3m1!5s0x479fc1a8e70d7c1b:0x92dd4312ee42f2f8!4m22!1m10!3m9!1s0x479fc1a8e70717f3:0x316fca3a5c2c03e!2sBohemian+Hotel!5m2!4m1!1i2!8m2!3d49.0186323!4d12.091916!16s%2Fg%2F11byp8407w!3m10!1s0x479fc1a8e70717f3:0x316fca3a5c2c03e!5m2!4m1!1i2!8m2!3d49.0186323!4d12.091916!9m1!1b1!16s%2Fg%2F11byp8407w

konsumer commented 4 months ago

There is no way to auto-detect that a string is URL-encoded over base64, and personally I think it would be a confusing option in the UI, since it's a specific, but not often usecase. You can easily do it yourself, though. I did this in dev-console:

// decode url, encode as base64
const getBytes = s => btoa(decodeURIComponent(s))

getBytes('!3m1!5s0x479fc1a8e70d7c1b:0x92dd4312ee42f2f8!4m22!1m10!3m9!1s0x479fc1a8e70717f3:0x316fca3a5c2c03e!2sBohemian+Hotel!5m2!4m1!1i2!8m2!3d49.0186323!4d12.091916!16s%2Fg%2F11byp8407w!3m10!1s0x479fc1a8e70717f3:0x316fca3a5c2c03e!5m2!4m1!1i2!8m2!3d49.0186323!4d12.091916!9m1!1b1!16s%2Fg%2F11byp8407w')

@adibalcan, your example doesn't appear to be valid protobuf, though (it converted to hex when I pasted base64):

Screenshot 2024-04-25 at 8 14 13 PM

Do you have more info?