Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library url

URI parsing, composition, and relative URL resolution.

A URL is represented as a table with the following entries:

  • scheme
  • fragment
  • query
  • params
  • authority
  • userinfo
  • path
  • port
  • password
These correspond to these parts of a URL (some may be nil):
scheme://userinfo@password:authority:port/path;params?query#fragment

Authors:
Diego Nehab
Eddie Bell <ejlbell@gmail.com>

Source: http://nmap.org/svn/nselib/url.lua

Functions

absolute (base_url, relative_url)

Builds an absolute URL from a base and a relative URL according to RFC 2396.

build (parsed)

Rebuilds a parsed URL from its components.

build_path (parsed, unsafe)

Builds a path component from its segments, escaping protected characters.

build_query (query)

Builds a query string from a table.

escape (s)

Encodes a string into its escaped hexadecimal representation.

parse (url, default)

Parses a URL and returns a table with all its parts according to RFC 2396.

parse_path (path)

Breaks a path into its segments, unescaping the segments.

parse_query (query)

Breaks a query string into name/value pairs.

unescape (s)

Decodes an escaped hexadecimal string.



Functions

absolute (base_url, relative_url)

Builds an absolute URL from a base and a relative URL according to RFC 2396.

Parameters

  • base_url: A base URL.
  • relative_url: A relative URL.

Return value:

The corresponding absolute URL.
build (parsed)

Rebuilds a parsed URL from its components.

Components are protected if any reserved or disallowed characters are found.

Parameters

  • parsed: Parsed URL, as returned by parse.

Return value:

A string with the corresponding URL.
build_path (parsed, unsafe)

Builds a path component from its segments, escaping protected characters.

Parameters

  • parsed: Path segments.
  • unsafe: If true, segments are not protected before path is built.

Return value:

The corresponding path string
build_query (query)

Builds a query string from a table.

This is the inverse of parse_query. Both the parameter name and value are subject to URL encoding.

Parameters

  • query: A dictionary table where table['name'] = value.

Return value:

A query string (like "name=value2&name=value2").
escape (s)

Encodes a string into its escaped hexadecimal representation.

Parameters

  • s: Binary string to be encoded.

Return value:

Escaped representation of string.
parse (url, default)

Parses a URL and returns a table with all its parts according to RFC 2396.

The following grammar describes the names given to the URL parts.

<url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment>
<authority> ::= <userinfo>@<host>:<port>
<userinfo> ::= <user>[:<password>]
<path> :: = {<segment>/}<segment>

The leading / in /<path> is considered part of <path>.

Parameters

  • url: URL of request.
  • default: Table with default values for each field.

Return value:

A table with the following fields, where RFC naming conventions have been preserved: scheme, authority, userinfo, user, password, host, port, path, params, query, and fragment.
parse_path (path)

Breaks a path into its segments, unescaping the segments.

Parameters

  • path: A path to break.

Return value:

A table with one entry per segment.
parse_query (query)

Breaks a query string into name/value pairs.

This function takes a <query> of the form "name1=value1&name2=value2" and returns a table containing the name-value pairs, with the name as the key and the value as its associated value. Both the name and the value are subject to URL decoding.

Parameters

  • query: Query string.

Return value:

A table of name-value pairs following the pattern table["name"] = value.
unescape (s)

Decodes an escaped hexadecimal string.

Parameters

  • s: Hexadecimal-encoded string.

Return value:

Decoded string.

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]