Welcome Guest, Not a member yet? Register   Sign In
permitted_uri_chars with slash
#1

Hello,
adding in url address like
Code:
encodeURIComponent("Collinsfield street 5/a")

I found that ci3 does not find this ulr even after in app application/config/config.php file in line

PHP Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-+,\.'

I added 2 chars at end of condition.
PHP Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-+,\.\/'


Which is the correct way?

    Thanks!
Reply
#2

Why not just use urlencode?

https://www.tools4noobs.com/online_php_f...urlencode/

Works for me.
Reply
#3

(This post was last modified: 06-06-2016, 09:31 PM by mstdmstd.)

urlencode - is php function
I run from javascript in popup page :

Code:
   function ViewonGoogleMap() {
       //var Addr = encodeURIComponent('Australia ' + ' ' + $('#postal_code').val() + ' ' + $('#town').val() + ' ' + $('#street_addr').val());
       var Addr = encodeURI('Australia ' + ' ' + $('#postal_code').val() + ' ' + $('#town').val() + ' ' + $('#street_addr').val());
       var HRef = '{{ base_url }}geocode.php?addr=' + Addr;
       $.getJSON(HRef, function (data) {
           //alert( var_dump(data) )
           var results = data['results']
           var geometry = results[0].geometry
           var location = geometry.location
           ShowGoogleMap(location.lat, location.lng, Addr)
       });
   }

   function ShowGoogleMap(lat, lng, Addr) {
       var screen_popup_width_indent = 50
       var screen_popup_height_indent = 60
       var H = screen.availHeight - screen_popup_height_indent;
       var W = screen.availWidth - screen_popup_width_indent;
       var TopCoord = screen_popup_height_indent / 2
       var LeftCoord = screen_popup_width_indent / 2
       var naProps = window.open("{{ base_url }}admin/hostel/show_map/addr/" + encodeURIComponent(Addr) + "/lat/" + encodeURIComponent(lat) + "/lng/" + encodeURIComponent(lng),
               "ShowGoogleMap", "status=no,modal=yes,scrollbars=yes,width=" + W + ",height=" + H + ",left=" + LeftCoord + ", top=" + TopCoord);
   }

Using encodeURIComponent or encodeURI gives the same error...

geocode.php has lines with urlencode in address:

PHP Code:
<?
$addr= $_GET['addr'];
echo file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".urlencode($addr)."&sensor=true"); // 1600+Amphitheatre+Parkway,+Mountain+View,+CA
?>
Reply
#4

For JS if you want to encode backslashes then you should be able to use:


Code:
.replace(/\\/g, '%5C')

See here: http://locutus.io/php/url/urlencode/
They aren't showing the encoding of backslashes, but it would be easy to see that my little snippet is your solution, right?
Reply
#5

(This post was last modified: 06-13-2016, 04:00 AM by mstdmstd.)

Sorry, both cases do not work:

Code:
       var street_addr= $('#street_addr').val()  // Has Value "Collinsfield street 5/a"
       street_addr= street_addr. replace( /\\/g, '%5C' )
       alert( "street_addr::"+street_addr ) // It shows the same "Collinsfield street 5/a" value, so ref link is still invalid


Using of urlencode function from url you left will give string like
Code:
 Collinsfield+street+5%2Fa

But ref is invalid
My current configuration :

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-+,\.\/'; //Collinsfield street 5/a
Reply




Theme © iAndrew 2016 - Forum software by © MyBB