Giter Site home page Giter Site logo

Comments (1)

marshallpierce avatar marshallpierce commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.