[asterisk-bugs] [Asterisk 0018037]: [patch] func_uri could use a QSFIELD function to parse x-www-form-urlencoded data
Asterisk Bug Tracker
noreply at bugs.digium.com
Thu Sep 23 11:22:52 CDT 2010
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=18037
======================================================================
Reported By: wdoekes
Assigned To:
======================================================================
Project: Asterisk
Issue ID: 18037
Category: Functions/func_uri
Reproducibility: always
Severity: feature
Priority: normal
Status: ready for testing
Asterisk Version: 1.6.2.13
JIRA: SWP-2294
Regression: No
Reviewboard Link:
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2010-09-23 10:18 CDT
Last Modified: 2010-09-23 11:22 CDT
======================================================================
Summary: [patch] func_uri could use a QSFIELD function to
parse x-www-form-urlencoded data
Description:
Hi,
I've added a QSFIELD function to func_uri.c to get fields from a
querystring. I thought this would be an acceptable way to read an ordered
dictionary gotten through e.g. func_curl.
[Synopsis]
Gets a single field from a application/x-www-form-urlencoded query string.
[Description]
Returns the URI-decoded content from the <index>-th field with name
<field>
from query string found in variable <varname>.
[Syntax]
QSFIELD(varname,field[,index])
Example:
exten =>
_IDX!,n,Set(qsdata=field1=pe%20%25%40%26%3dna&field1=pe+na2&field2=pena3)
exten => _IDX!,n,NoOp(qsdata is ${qsdata})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field1,-1)})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field2,-1)})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field1,0)})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field2,0)})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field1,1)})
exten => _IDX!,n,NoOp(qstest ${QSFIELD(qsdata,field2,1)})
Set("qsdata=field1=pe%20%25%40%26%3dna&field1=pe+na2&field2=pena3")
NoOp("qsdata is field1=pe%20%25%40%26%3dna&field1=pe+na2&field2=pena3")
NoOp("qstest pe na2")
NoOp("qstest pena3")
NoOp("qstest pe %@&=na")
NoOp("qstest pena3")
NoOp("qstest pe na2")
NOTICE[4224]: func_uri.c:243 qsfield: Field field2= not found in query
string from qsdata on requested index
NoOp("qstest ")
======================================================================
----------------------------------------------------------------------
(0127331) wdoekes (reporter) - 2010-09-23 11:22
https://issues.asterisk.org/view.php?id=18037#c127331
----------------------------------------------------------------------
Hahaha. Okay, here an example:
Set(url=${FUNCTION_TO_GET_URL_TEMPLATE()}) ;; e.g.
http://example.com/?did={did}&callerid={callerid}
Set(url=${STRREPLACE(url,"{did}","${EXTEN}")})
Set(url=${STRREPLACE(url,"{callerid}","${CALLERID(num)}")})
Set(qs=${CURL(url)}) ;; e.g. timeout=10&destination=%2B123456789
Set(timeout=${QSFIELD(qs,timeout)})
Set(destination=${QSFIELD(qs,destination)})
Dial(SIP/trunk/${destination},${timeout})
Issue History
Date Modified Username Field Change
======================================================================
2010-09-23 11:22 wdoekes Note Added: 0127331
======================================================================
More information about the asterisk-bugs
mailing list