Comments (1)
This is correct behavior, actually. The issue is that URL_SAFE
base64 is not the same as URL encoding/decoding.
URL encoding is what maps a space
to %20
, /
to %2F
, etc, and is applied, piece by piece, when assembling a URL. This is necessary to be able to represent a path containing a /
without interpreting the /
as the separator between path components, and other such issues.
URL-safe Base64 is a Base64 variant that uses -
and _
instead of +
and /
to avoid any further transformation when being used in a URL.
So, what you have above is a complete URL that includes as part of it a URL-encoded non-url-safe Base64 section. You can see it's been URL encoded because it has things like %2F
(hex 0x2F
is the ASCII encoding of /
) and %2B
(which would be +
).
More specifically, that's a URL with a query string composed of query key/value pair, and the part you want is the query value. The RFCs around URL encoding are a mess, and the conventions used by HTML forms go beyond what the base URI/URL RFCs do (e.g. using +
to represent
-- what if you really wanted a plus, not a space?), so there isn't a single answer for how to parse or construct these things, but basically what you want to do is get to this part: payload=FZkVZv
, extract the FZkVZv...
part, URL-decode that (undo the %
encoding), strip whitespace (which base64
can optionally do for you), and then base64 decode the result with base64::STANDARD
.
from rust-base64.
Related Issues (20)
- Restore base64::{encode, decode} functions HOT 11
- Thank you
- How do I change the padding character? HOT 1
- Using this crate easier HOT 2
- DecoderReader accepts incorrect input HOT 2
- Design choices HOT 5
- How come I can't decode this string? HOT 1
- `DecoderReader` probably should accept `BufRead` instead of `Read` HOT 1
- make Alphabet::from_str_unchecked public HOT 3
- Replacement for base64::decode()? HOT 12
- How to generate the base64 format like openssl command HOT 3
- `DecoderReader` does not respect `with_decode_allow_trailing_bits` HOT 4
- how to encode image bytes to string? HOT 1
- GeneralPurpose engine should implement Clone and Debug HOT 6
- Make `Alphabet::from_str_unchecked` `pub const unsafe` HOT 5
- Calling `EncoderStringWriter::write` successively does not equal `EncoderStringWriter::write_all` HOT 2
- Make `encoded_len` const HOT 3
- Add encode_vec() HOT 4
- Question: best way to access inner field values HOT 5
- SIMD support? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-base64.