.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "WWW::Form::UrlEncoded 3pm" .TH WWW::Form::UrlEncoded 3pm "2018-10-20" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" WWW::Form::UrlEncoded \- parser and builder for application/x\-www\-form\-urlencoded .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use WWW::Form::UrlEncoded qw/parse_urlencoded build_urlencoded/; \& \& my $query_string = "foo=bar&baz=param"; \& my @params = parse_urlencoded($query_string); \& # (\*(Aqfoo\*(Aq,\*(Aqbar\*(Aq,\*(Aqbaz\*(Aq,\*(Aqparam\*(Aq) \& \& my $query_string = build_urlencoded(\*(Aqfoo\*(Aq,\*(Aqbar\*(Aq,\*(Aqbaz\*(Aq,\*(Aqparam\*(Aq); \& # "foo=bar&baz=param"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" WWW::Form::UrlEncoded provides application/x\-www\-form\-urlencoded parser and builder. This module aims to have compatibility with other \s-1CPAN\s0 modules like HTTP::Body's urlencoded parser. .PP This module try to use WWW::Form::UrlEncoded::XS by default and fail to it, use WWW::Form::UrlEncoded::PP instead .SS "Parser rules" .IX Subsection "Parser rules" WWW::Form::UrlEncoded parsed string in this rule. .ie n .IP "1. Split application/x\-www\-form\-urlencoded payload by ""&"" (U+0026) or "";"" (U+003B)" 4 .el .IP "1. Split application/x\-www\-form\-urlencoded payload by \f(CW&\fR (U+0026) or \f(CW;\fR (U+003B)" 4 .IX Item "1. Split application/x-www-form-urlencoded payload by & (U+0026) or ; (U+003B)" .PD 0 .ie n .IP "2. Ready empty array to store ""name"" and ""value""" 4 .el .IP "2. Ready empty array to store \f(CWname\fR and \f(CWvalue\fR" 4 .IX Item "2. Ready empty array to store name and value" .IP "3. For each divided string, apply next steps." 4 .IX Item "3. For each divided string, apply next steps." .RS 4 .ie n .IP "1. If first character of string is \*(Aq \*(Aq (U+0020 \s-1SPACE\s0), remove it." 4 .el .IP "1. If first character of string is \f(CW\*(Aq \*(Aq\fR (U+0020 \s-1SPACE\s0), remove it." 4 .IX Item "1. If first character of string is (U+0020 SPACE), remove it." .ie n .IP "2. If string has ""="", let \fBname\fR be substring from start to first ""="", but excluding first ""="", and remains to be \fBvalue\fR. If there is no strings after first ""="", \fBvalue\fR to be empty string """". If first ""="" is first character of the string, let \fBkey\fR be empty string """". If string does not have any ""="", all of the string to be \fBkey\fR and \fBvalue\fR to be empty string """"." 4 .el .IP "2. If string has \f(CW=\fR, let \fBname\fR be substring from start to first \f(CW=\fR, but excluding first \f(CW=\fR, and remains to be \fBvalue\fR. If there is no strings after first \f(CW=\fR, \fBvalue\fR to be empty string \f(CW``''\fR. If first \f(CW=\fR is first character of the string, let \fBkey\fR be empty string \f(CW``''\fR. If string does not have any \f(CW=\fR, all of the string to be \fBkey\fR and \fBvalue\fR to be empty string \f(CW``''\fR." 4 .IX Item "2. If string has =, let name be substring from start to first =, but excluding first =, and remains to be value. If there is no strings after first =, value to be empty string """". If first = is first character of the string, let key be empty string """". If string does not have any =, all of the string to be key and value to be empty string """"." .ie n .IP "3. replace all ""+"" (U+002B) with \*(Aq \*(Aq (U+0020 \s-1SPACE\s0)." 4 .el .IP "3. replace all \f(CW+\fR (U+002B) with \f(CW\*(Aq \*(Aq\fR (U+0020 \s-1SPACE\s0)." 4 .IX Item "3. replace all + (U+002B) with (U+0020 SPACE)." .IP "4. unescape \fBname\fR and \fBvalue\fR. push them to the array." 4 .IX Item "4. unescape name and value. push them to the array." .RE .RS 4 .RE .IP "4. return the array." 4 .IX Item "4. return the array." .PD .SS "Test data" .IX Subsection "Test data" .Vb 10 \& \*(Aqa=b&c=d\*(Aq => ["a","b","c","d"] \& \*(Aqa=b;c=d\*(Aq => ["a","b","c","d"] \& \*(Aqa=1&b=2;c=3\*(Aq => ["a","1","b","2","c","3"] \& \*(Aqa==b&c==d\*(Aq => ["a","=b","c","=d"] \& \*(Aqa=b& c=d\*(Aq => ["a","b","c","d"] \& \*(Aqa=b; c=d\*(Aq => ["a","b","c","d"] \& \*(Aqa=b; c =d\*(Aq => ["a","b","c ","d"] \& \*(Aqa=b;c= d \*(Aq => ["a","b","c"," d "] \& \*(Aqa=b&+c=d\*(Aq => ["a","b"," c","d"] \& \*(Aqa=b&+c+=d\*(Aq => ["a","b"," c ","d"] \& \*(Aqa=b&c=+d+\*(Aq => ["a","b","c"," d "] \& \*(Aqa=b&%20c=d\*(Aq => ["a","b"," c","d"] \& \*(Aqa=b&%20c%20=d\*(Aq => ["a","b"," c ","d"] \& \*(Aqa=b&c=%20d%20\*(Aq => ["a","b","c"," d "] \& \*(Aqa&c=d\*(Aq => ["a","","c","d"] \& \*(Aqa=b&=d\*(Aq => ["a","b","","d"] \& \*(Aqa=b&=\*(Aq => ["a","b","",""] \& \*(Aq&\*(Aq => ["","","",""] \& \*(Aq=\*(Aq => ["",""] \& \*(Aq\*(Aq => [] .Ve .SH "FUNCTION" .IX Header "FUNCTION" .ie n .IP "@param = parse_urlencoded($str:String)" 4 .el .IP "\f(CW@param\fR = parse_urlencoded($str:String)" 4 .IX Item "@param = parse_urlencoded($str:String)" parse \f(CW$str\fR and return Array that contains key-value pairs. .ie n .IP "$param:ArrayRef = parse_urlencoded_arrayref($str:String)" 4 .el .IP "\f(CW$param:ArrayRef\fR = parse_urlencoded_arrayref($str:String)" 4 .IX Item "$param:ArrayRef = parse_urlencoded_arrayref($str:String)" parse \f(CW$str\fR and return ArrayRef that contains key-value pairs. .ie n .IP "$string = build_urlencoded(@param)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(@param)" 4 .IX Item "$string = build_urlencoded(@param)" .PD 0 .ie n .IP "$string = build_urlencoded(@param, $delim)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(@param, \f(CW$delim\fR)" 4 .IX Item "$string = build_urlencoded(@param, $delim)" .ie n .IP "$string = build_urlencoded(\e@param)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(\e@param)" 4 .IX Item "$string = build_urlencoded(@param)" .ie n .IP "$string = build_urlencoded(\e@param, $delim)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(\e@param, \f(CW$delim\fR)" 4 .IX Item "$string = build_urlencoded(@param, $delim)" .ie n .IP "$string = build_urlencoded(\e%param)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(\e%param)" 4 .IX Item "$string = build_urlencoded(%param)" .ie n .IP "$string = build_urlencoded(\e%param, $delim)" 4 .el .IP "\f(CW$string\fR = build_urlencoded(\e%param, \f(CW$delim\fR)" 4 .IX Item "$string = build_urlencoded(%param, $delim)" .PD build urlencoded string from \fBparam\fR. build_urlencoded accepts arrayref and hashref values. .Sp .Vb 5 \& build_urlencoded( foo => 1, foo => 2); \& build_urlencoded( foo => [1,2] ); \& build_urlencoded( [ foo => 1, foo => 2 ] ); \& build_urlencoded( [foo => [1,2]] ); \& build_urlencoded( {foo => [1,2]} ); .Ve .Sp If \f(CW$delim\fR parameter is passed, this function use it instead of using \f(CW\*(C`&\*(C'\fR. .ie n .IP "$string = build_urlencoded_utf8(...)" 4 .el .IP "\f(CW$string\fR = build_urlencoded_utf8(...)" 4 .IX Item "$string = build_urlencoded_utf8(...)" This function is almost same as \f(CW\*(C`build_urlencoded\*(C'\fR. build_urlencoded_utf8 call \f(CW\*(C`utf8::encode\*(C'\fR for all parameters. .SH "ENVIRONMENT VALUE" .IX Header "ENVIRONMENT VALUE" .IP "\(bu" 4 \&\s-1WWW_FORM_URLENCODED_PP\s0 .Sp If true, WWW::Form::UrlEncoded force to load WWW::Form::UrlEncoded::PP. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1CPAN\s0 already has some application/x\-www\-form\-urlencoded parser modules like these. .IP "URL::Encode" 4 .IX Item "URL::Encode" .PD 0 .IP "URL::Encode::XS" 4 .IX Item "URL::Encode::XS" .IP "Text::QueryString" 4 .IX Item "Text::QueryString" .PD .PP They does not fully compatible with WWW::Form::UrlEncoded. Handling of empty key-value and supporting separator characters are different. .SH "LICENSE" .IX Header "LICENSE" Copyright (C) Masahiro Nagano. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "AUTHOR" .IX Header "AUTHOR" Masahiro Nagano