Email or username:

Password:

Forgot your password?
Garrit πŸ‘Ÿ

Encountered a fun little bug at work that I thought is worth sharing.

Beware of Base64 encoded strings:
garrit.xyz/posts/2024-04-15-be

6 comments
Garrit πŸ‘Ÿ

My analytics just went wild. This apparently made it to the top of Hacker News. πŸ‘€

news.ycombinator.com/item?id=4

Anders Eknert

@garritfra yes, and to make things more fun, the -w flag isn’t available in all versions (like on Mac). I remember having to make something conditional about that in a script at some distant past.

Garrit πŸ‘Ÿ

@anderseknert I can only imagine. A great portion of my time debugging was also lost to the fact that the version on MacOS doesn't wrap lines at all. I only noticed this issue when testing inside the pod on production. πŸ˜…

How the hell can such a "standard util" be so inconsistent across platforms?

Anders Eknert

@garritfra Totally. One major split is with the GNU tools and the BSD ones, where Apple wouldn't touch the former if their lives depended on it. The tools are of course easy to install yourself on Mac, but portability is still a concern as soon as someone else is going to use it. Almost like there should be a "jQuery for shell scripts", normalizing commands between environments. Perhaps there is and some reply guy will be happy to tell me about it. If so, feel free to do so :)

Colin the Mathmo

@garritfra Yeah, sorry about that.

At least we are reminded again that some forums are full of self-important assholes who *always* know better and *never* make mistakes that could have been prevented by reading every manpage in detail.

It's "discussions" like the one on the orange site that discourages anyone from ever writing up their mistakes, and the world is poorer for it.

Thank you for your write-up.

Balu

@garritfra I mean, it's right there:

```
$ base64 --help
Usage: base64 [OPTION]... [FILE]
[...]
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).
Use 0 to disable line wrapping
[...]
```

Unless you are on MacOS, then base64 doesn't have a default line wrapping. =)

Go Up