Skip to content

Document a new functions to encode and decode parts of URI #3279

Closed
@TarantoolBot

Description

@TarantoolBot

Related dev. issue(s): tarantool/tarantool#3682

Product: Tarantool
Since: 2.11
Root document:

SME: @ ligurio

Details

New functions uri.escape() and uri.unescape() have been introduced.
First one allows to escape symbols to a string and second one to
unescape symbols to a string according to RFC 3986 [1].

Examples:

tarantool> uri.escape("тарантул")
---
- '%D1%82%D0%B0%D1%80%D0%B0%D0%BD%D1%82%D1%83%D0%BB'
...

tarantool> uri.unescape("%D1%82%D0%B0%D1%80%D0%B0%D0%BD%D1%82%D1%83%D0%BB")
---
- тарантул
...

uri.escape() accepts a string that will be encoded and optionally a
table with encoding options: string with unreserved symbols that will
not be encoded and boolean option that enables/disables encoding of a
space characters as '+'. By default uri.escape() uses a set of
unreserved symbols defined in RFC 3986 ("2.3. Unreserved Characters")
and encoding of space characters as '+' is disabled. Table with default
encoding options is defined as uri.RFC3986.

uri.unescape() accepts a string that will be decoded and optionally a
table with decoding options: string with unreserved symbols (these
symbols are actually unused by decoding function) and boolean option
that enables/disables decoding of '+' as a space character. Table with
default decoding options is defined as uri.RFC3986.

See detailed description in RFC "http: add percent-encoding/decoding of
query string in request" [2].

NO_WRAP

  1. Uniform Resource Identifier (URI): Generic Syntax
    https://datatracker.ietf.org/doc/html/rfc3986
  2. https://www.notion.so/tarantool/http-add-percent-encoding-decoding-of-query-string-in-request-76a2425a4c4744a1a72643527a4fe7f7
    NO_WRAP
    Requested by @ ligurio in tarantool/tarantool@5ebe186.

Metadata

Metadata

Assignees

Labels

2.112.11 release and the associated technical debtfeatureA new functionalityuri

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions