Module: Merb::Parse

Module | Merb::Parse
In: | lib/merb-core/dispatch/request_parsers.rb

### Methods

escape escape_xml multipart params_to_query_string query unescape

### Constants

NAME_REGEX | = | /Content-Disposition:.* name="?([^\";]*)"?/ni.freeze
CONTENT_TYPE_REGEX | = | /Content-Type: (.*)\r\n/ni.freeze
FILENAME_REGEX | = | /Content-Disposition:.* filename="?([^\";]*)"?/ni.freeze
CRLF | = | "\r\n".freeze
EOL | = | CRLF

### Public Class methods

escape(s)

#### Parameters

s<String>: | String to URL escape.

#### returns

String: | The escaped string.

:api: public

escape_xml(s)

#### Parameters

s<String>: | String to XML escape.

#### returns

String: | The escaped string.

:api: public

multipart(request, boundary, content_length)

#### Parameters

request<IO>: | The raw request.
boundary<String>: | The boundary string.
content_length<Fixnum>: | The length of the content.

#### Raises

ControllerExceptions::MultiPartParseError: | Failed to parse request.

#### Returns

Hash: | The parsed request.

:api: plugin

params_to_query_string(value, prefix = nil)

#### Parameters

value<Array, Hash, Dictionary ~to_s>: | The value for the query string.
prefix<~to_s>: | The prefix to add to the query string keys.

#### Returns

String: | The query string.

#### Alternatives

If the value is a string, the prefix will be used as the key.

#### Examples

      params_to_query_string(10, "page")
        # => "page=10"
      params_to_query_string({ :page => 10, :word => "ruby" })
        # => "page=10&word=ruby"
      params_to_query_string({ :page => 10, :word => "ruby" }, "search")
        # => "search[page]=10&search[word]=ruby"
      params_to_query_string([ "ice-cream", "cake" ], "shopping_list")
        # => "shopping_list[]=ice-cream&shopping_list[]=cake"

:api: plugin

query(query_string, delimiter = '&;', preserve_order = false)

#### Parameters

query_string<String>: | The query string.
delimiter<String>: | The query string divider. Defaults to "&".
preserve_order<Boolean>: | Preserve order of args. Defaults to false.

#### Returns

Mash: | The parsed query string (Dictionary if preserve_order is set).

#### Examples

      Merb::Parse.query("bar=nik&post[body]=heya")
        # => { :bar => "nik", :post => { :body => "heya" } }

:api: plugin

unescape(s)

#### Parameter

s<String>: | String to URL unescape.

#### returns

String: | The unescaped string.

:api: public

[Validate]