Uri does not encode (or double-encodes) non-URL safe base64 path segments. #57015
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
type-documentation
A request to add or improve documentation
When attempting to create a
Uri
with a base64 encoded path segment value that is NOT URL safe (i.e containing illegal characters), it does not encode it (or double-encodes it when encoding it prior to creating the instance), when either creating a URI from scratch, or when replacing an existing one.In other words, when encoding the base64 value using
Uri.encodeComponent
and creating theUri
usingUri.parse
, it properly converts the unsafe==
into properly encoded%3D%3D
characters.However, when creating the
Uri
either from its constructor, or when callingreplace
on an existing one, when placing an unencoded base64 value as a path segment, it returns==
when callingtoString
on the resulting instance. Furthermore, when encoding the value usingUri.encodeComponent
and placing it as a path segment, it double-encodes the already encoded%3D%3D
value to%253D%253D
instead.Here is code that highlights this issue:
Also available as a DartPad.
Currently running the following Dart version on macOS 14.5:
Dart SDK version: 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"
The text was updated successfully, but these errors were encountered: