Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.3

Request #15384 Make rawurlencode optional
Submitted: 2008-12-23 21:02 UTC
From: snytkine Assigned: mj
Status: Closed Package: URI_Template (version 0.3.0)
PHP Version: 5.2.0 OS: RHEL4
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 17 + 29 = ?

 
 [2008-12-23 21:02 UTC] snytkine (Dmitri Snytkine)
Description: ------------ Hello! Sometimes I need to pass the %s or %d as one of the values and I want the parsed url to include the same value unchanged. The rawurlencode messes it up! Basically I want the URI_Template to make all substitutions but the result URL must have the %s or %d to I can use it as input for sprintf() Can you include the second param to substitue($values, $urlencode = true) then only do the urlencode if $urlencode === true This would really help. Also, if was not able to simple redefine the substitute() in a sub-class because vars of $template and $values are private. Maybe you should change them to protected, so people can extend this class. Thank you.

Comments

 [2008-12-27 04:27 UTC] doconnor (Daniel O'Connor)
The private / protected bit appears already done in CVS, and there's now a quick patch for encode - I take it thats what you meant, Dmitri?
 [2008-12-27 17:33 UTC] snytkine (Dmitri Snytkine)
I saw the version in CVS, looks good, now it will be easy to redefine the substitute() methods but you can also add a second arg to substitute() substitute($values, $urlEncode = true){ // then if($urlEncode){ $this->values = $values; /* Because it is common that a template contains several replacements, * we do the URL encoding here instead of in _substitute. */ foreach ($this->values as &$value) { if (is_array($value)) { $value = array_map('rawurlencode', $value); } else { $value = rawurlencode($value); } } } return preg_replace_callback('~(\{[^\}]+\})~', array($this, '_substitute'), $this->template); }
 [2009-12-22 01:47 UTC] mj (Martin Jansen)
-Status: Open +Status: Closed -Assigned To: +Assigned To: mj
The feature request has been implemented and will be part of the upcoming 0.3.1 release.