pub enum PathTokenError {
Empty,
Separator,
ParentDir,
CurDir,
NulByte,
Colon,
Unindexable,
}Expand description
Why a string is not a safe path token.
An untrusted string becomes a path component in several places: a blob’s
id/namespace (interpolated into its on-disk file path and cloud object
key), and a store_id/sid from an untrusted device invitation or restore code (the
name of a directory under stores/). All arrive from outside — an incoming
changeset authored by any write-capable member, or a pasted code anyone can
craft — so an unconstrained one could climb out of the directory it is joined
onto (.., a path separator, an absolute leading slash) and make a pulling or
joining device read, write, or recursively delete an arbitrary location, or —
too short / not aligned to a char boundary — crash a blob’s partition-prefix
slice. A string that trips any of these is bad data, refused before a path is
built or used.
Variants§
Empty
The token is empty — no file name to write, no key to form.
Separator
The token contains a path separator (/ or \), so joining it onto a
directory would descend into (or, with a leading separator, replace) the
path rather than name a single child.
ParentDir
The token is exactly .., which names the parent of the directory it is
joined onto rather than a child. A trailing .. component is normalized
away when the path is resolved, so the join lands on the parent.
CurDir
The token is exactly ., which names the directory it is joined onto
itself rather than a child. Like .., a trailing . component is
normalized away, so stores/. resolves to stores’s parent (the
data dir) — an escape just as .. is.
NulByte
The token contains a NUL byte, which truncates the path at the OS boundary.
Colon
The token contains a :, which on Windows names an alternate data stream
(file:stream) or a drive-relative reference (c:dir) rather than a child.
Unindexable
The dash-stripped id is too short, or splits a multi-byte char, to take the
two leading byte-pairs the {ab}/{cd} partition prefix needs.
Trait Implementations§
Source§impl Clone for PathTokenError
impl Clone for PathTokenError
Source§fn clone(&self) -> PathTokenError
fn clone(&self) -> PathTokenError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PathTokenError
impl Debug for PathTokenError
Source§impl Display for PathTokenError
impl Display for PathTokenError
Source§impl Error for PathTokenError
impl Error for PathTokenError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<PathTokenError> for CachedLocatorRemovalError
impl From<PathTokenError> for CachedLocatorRemovalError
Source§fn from(source: PathTokenError) -> Self
fn from(source: PathTokenError) -> Self
Source§impl From<PathTokenError> for LocalBlobRemovalError
impl From<PathTokenError> for LocalBlobRemovalError
Source§fn from(source: PathTokenError) -> Self
fn from(source: PathTokenError) -> Self
Source§impl From<PathTokenError> for LocalBlobStoreError
impl From<PathTokenError> for LocalBlobStoreError
Source§fn from(source: PathTokenError) -> Self
fn from(source: PathTokenError) -> Self
Source§impl From<PathTokenError> for RequiredLocalBlobPathError
impl From<PathTokenError> for RequiredLocalBlobPathError
Source§fn from(source: PathTokenError) -> Self
fn from(source: PathTokenError) -> Self
Source§impl From<PathTokenError> for StoreBlobFileError
impl From<PathTokenError> for StoreBlobFileError
Source§fn from(source: PathTokenError) -> Self
fn from(source: PathTokenError) -> Self
Source§impl PartialEq for PathTokenError
impl PartialEq for PathTokenError
impl Eq for PathTokenError
impl StructuralPartialEq for PathTokenError
Auto Trait Implementations§
impl Freeze for PathTokenError
impl RefUnwindSafe for PathTokenError
impl Send for PathTokenError
impl Sync for PathTokenError
impl Unpin for PathTokenError
impl UnsafeUnpin for PathTokenError
impl UnwindSafe for PathTokenError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.