Module ostree_ext::refescape

source ·
Expand description

Escape strings for use in ostree refs.

It can be desirable to map arbitrary identifiers, such as RPM/dpkg package names or container image references (e.g. docker://quay.io/examplecorp/os:latest) into ostree refs (branch names) which have a quite restricted set of valid characters; basically alphanumeric, plus /, -, _.

This escaping scheme uses _ in a similar way as a \ character is used in Rust unicode escaped values. For example, : is _3A_ (hexadecimal). Because the empty path is not valid, // is escaped as /_2F_ (i.e. the second / is escaped).

Functions§

  • Compute a string suitable for use as an OSTree ref, where s can be a (nearly) arbitrary UTF-8 string. This requires a non-empty prefix.
  • Remove a prefix from an ostree ref, and return the unescaped remainder.