Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

util.Base64Encode does stupid things #3450

Open FredyH opened 6 years ago

FredyH commented 6 years ago

Details

util.Base64Encode places a newline after a specific number of characters and also returns nil when you provide an empty string. For comparison, this is what the same (correct!) function in JS does: chrome_2018-04-21_19-34-12

Steps to reproduce

Just run the function.

willox commented 6 years ago

so it adds newlines because of some historic use of e-mail or something, and most parsers should cope with that. i could see it messing up if appended to URLs or something, might be best to remove it.

will look in to the empty string stuff though

FredyH commented 6 years ago

I'd say that almost all (if not all) parsers can definitely deal with it if it does not contain any newlines. The problem arises when you want to base64 encode something so that you can use it in URLs or similar, where newlines obviously break things.

robotboy655 commented 6 years ago

Related: https://github.com/Facepunch/garrysmod-issues/issues/3359

thegrb93 commented 3 years ago

so it adds newlines because of some historic use of e-mail or something, and most parsers should cope with that. i could see it messing up if appended to URLs or something, might be best to remove it.

will look in to the empty string stuff though

I have to gsub out the newlines to make the encoded uris work with chromium.