FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » who is changing dots into underscores in my variable names in REST?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
who is changing dots into underscores in my variable names in REST? [message #169704] Thu, 23 September 2010 16:32 Go to next message
jrobinss is currently offline  jrobinss
Messages: 3
Registered: September 2010
Karma: 0
Junior Member
Hi all,

I searched high and low for a precise answer to this question, and
haven't found, so here goes.

I have a REST web service written in PHP (installation: Wamp with PHP
5.3.0).
Whether it receives
http://foo.bar/service?first.second=glob
or else
http://foo.bar/service?first_second=glob
it does exactly the same: it thinks it's receiving first_second.

Basically, dots are changed into underscores in the variable name
before being dispatched.


I understand that it happens, and I can live with it. But I can't find
any documentation about this, which bothers me. }:-[


This is what I found...

http://php.net/manual/en/reserved.variables.get.php
"The GET variables are passed through urldecode(). "

However I ran a simple test, and urldecode() doesn't replace dots with
underscores. :-(

I also understand that PHP may (magically) enforce filters
http://www.php.net/manual/en/filter.filters.php

I tested a number of them (with default settings), and also couldn't
find anything that changes "." to "_".


Here's the question: would anyone have a link that documents this?
Thanks
--
JRobinss
Re: who is changing dots into underscores in my variable names in REST? [message #169705 is a reply to message #169704] Thu, 23 September 2010 16:38 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/23/2010 12:32 PM, jrobinss wrote:
>
> Hi all,
>
> I searched high and low for a precise answer to this question, and
> haven't found, so here goes.
>
> I have a REST web service written in PHP (installation: Wamp with PHP
> 5.3.0).
> Whether it receives
> http://foo.bar/service?first.second=glob
> or else
> http://foo.bar/service?first_second=glob
> it does exactly the same: it thinks it's receiving first_second.
>
> Basically, dots are changed into underscores in the variable name
> before being dispatched.
>
>
> I understand that it happens, and I can live with it. But I can't find
> any documentation about this, which bothers me. }:-[
>
>
> This is what I found...
>
> http://php.net/manual/en/reserved.variables.get.php
> "The GET variables are passed through urldecode()."
>
> However I ran a simple test, and urldecode() doesn't replace dots with
> underscores. :-(
>
> I also understand that PHP may (magically) enforce filters
> http://www.php.net/manual/en/filter.filters.php
>
> I tested a number of them (with default settings), and also couldn't
> find anything that changes "." to "_".
>
>
> Here's the question: would anyone have a link that documents this?
> Thanks
> --
> JRobinss

You're looking in the wrong place. This has nothing to do with PHP -
it's all part of the HTTP protocol.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: who is changing dots into underscores in my variable names in REST? [message #169706 is a reply to message #169704] Thu, 23 September 2010 16:47 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:0193eacf-5ced-412f-9b2d-f012e14e317e(at)i17g2000vbq(dot)googlegroups(dot)com,
jrobinss <julien(dot)robinson2(at)gmail(dot)com> typed:
> Hi all,
>
> I searched high and low for a precise answer to this
> question, and haven't found, so here goes.
>
> I have a REST web service written in PHP (installation:
> Wamp with PHP
> 5.3.0).
> Whether it receives
> http://foo.bar/service?first.second=glob
> or else
> http://foo.bar/service?first_second=glob
> it does exactly the same: it thinks it's receiving
> first_second.
>
> Basically, dots are changed into underscores in the
> variable name before being dispatched.
>
>
> I understand that it happens, and I can live with it. But I
> can't find any documentation about this, which bothers me.
> }:-[
>
>
> This is what I found...
>
> http://php.net/manual/en/reserved.variables.get.php
> "The GET variables are passed through urldecode(). "
>
> However I ran a simple test, and urldecode() doesn't
> replace dots with underscores. :-(
>
> I also understand that PHP may (magically) enforce filters
> http://www.php.net/manual/en/filter.filters.php
>
> I tested a number of them (with default settings), and also
> couldn't find anything that changes "." to "_".
>
>
> Here's the question: would anyone have a link that
> documents this? Thanks

I think you'll find that's happening in your browser or whatever s handling
your http; iits replacing what it considers illegal characters (which those
are) to an underscore. If yuo actually want a space in a URL you have to
code it as %20 and so on.

HTH,

Twayne`
Re: who is changing dots into underscores in my variable names in REST? [message #169714 is a reply to message #169704] Thu, 23 September 2010 19:38 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(jrobinss)

> I searched high and low for a precise answer to this question, and
> haven't found, so here goes.
>
> I have a REST web service written in PHP (installation: Wamp with PHP
> 5.3.0).
> Whether it receives
> http://foo.bar/service?first.second=glob
> or else
> http://foo.bar/service?first_second=glob
> it does exactly the same: it thinks it's receiving first_second.
>
> Basically, dots are changed into underscores in the variable name
> before being dispatched.

It's a relic in PHP from the old days of register_globals. When you have
a parameter named 'foo', it would have ended up as a global variable of
the same name. But some characters are not allowed in variable names,
hence they were replaced with underscores. I don't know if there is or
will be a way to disable this "feature", since it's not needed anymore.

> This is what I found...
>
> http://php.net/manual/en/reserved.variables.get.php
> "The GET variables are passed through urldecode(). "

See the second note and the section "Dots in incoming variable names" on
<http://www.php.net/manual/en/language.variables.external.php>.

Micha
Re: who is changing dots into underscores in my variable names in REST? [message #169715 is a reply to message #169706] Thu, 23 September 2010 19:38 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Twayne)

> I think you'll find that's happening in your browser or whatever s handling
> your http; iits replacing what it considers illegal characters (which those
> are) to an underscore. If yuo actually want a space in a URL you have to
> code it as %20 and so on.

What makes you think a dot (which is what the OP is talking about, not a
space) would be illegal in the query part of a URI? It's not even
required to escape it, you can write it as-is. And no browser changes
any char to an underscore, as this would corrupt the data. The reason
here is PHP itself.

Micha
Re: who is changing dots into underscores in my variable names in REST? [message #169730 is a reply to message #169714] Fri, 24 September 2010 08:20 Go to previous messageGo to next message
jrobinss is currently offline  jrobinss
Messages: 3
Registered: September 2010
Karma: 0
Junior Member
On Sep 23, 9:38 pm, Michael Fesser <neti...@gmx.de> wrote:
> See the second note and the section "Dots in incoming variable names" on
> <http://www.php.net/manual/en/language.variables.external.php>.

Many thanks, this is exactly what I was looking for!

(it's a shame that others would provide false answers with such a
assurance, I nearly went on a wild goose chase there, in HTTP or
Firefox docs)
(OTOH of course no one owes me anything, and any tip is appreciated)
(but if it's not an *answer* but rather a *tip* or general feeling,
it's probably better to make it look that way)
(oops, not wanting to start a flamewar, thanks to all, and peace on
earth to all men of goodwill)

--
JRobinss
Re: who is changing dots into underscores in my variable names in REST? [message #169767 is a reply to message #169715] Sat, 25 September 2010 19:24 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:pman969c3vmp063lumeg3kti07jsa5l4mm(at)mfesser(dot)de,
Michael Fesser <netizen(at)gmx(dot)de> typed:
> .oO(Twayne)
>
>> I think you'll find that's happening in your browser or
>> whatever s handling your http; iits replacing what it
>> considers illegal characters (which those are) to an
>> underscore. If yuo actually want a space in a URL you have
>> to code it as %20 and so on.
>
> What makes you think a dot (which is what the OP is talking
> about, not a space) would be illegal in the query part of a
> URI? It's not even required to escape it, you can write it
> as-is. And no browser changes any char to an underscore, as
> this would corrupt the data. The reason here is PHP itself.
>
> Micha

You might be right in retrospect; I do recall that changing several years
ago to where multiple dots were allowed. My mistake.

But both IE8 and FF will change a space to %20; I just tried it again. My
site.com turns into my%20site.com. It happens with a lot of other characters
too changing to their value instead of symbol.
HTH,

Twayne`
Re: who is changing dots into underscores in my variable names in REST? [message #169775 is a reply to message #169767] Sun, 26 September 2010 13:43 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Twayne)

> But both IE8 and FF will change a space to %20; I just tried it again. My
> site.com turns into my%20site.com. It happens with a lot of other characters
> too changing to their value instead of symbol.

That's correct, because some characters like spaces for example are not
allowed in any part of a URI, so they have to be encoded.

Micha
Re: who is changing dots into underscores in my variable names in REST? [message #169777 is a reply to message #169775] Sun, 26 September 2010 16:43 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:cdju96dvgbnmqm0br2t7n1ogkrnm8em6jq(at)mfesser(dot)de,
Michael Fesser <netizen(at)gmx(dot)de> typed:
> .oO(Twayne)
>
>> But both IE8 and FF will change a space to %20; I just
>> tried it again. My site.com turns into my%20site.com. It
>> happens with a lot of other characters too changing to
>> their value instead of symbol.
>
> That's correct, because some characters like spaces for
> example are not allowed in any part of a URI, so they have
> to be encoded.
>
> Micha

Exactly. Perhaps you can answer a question for me: The abiliity to use
multiple dots; are multiple dots allowed in IPV 4 ? Or are they an IPV 6
implementation? I though I had the papers on it but can't find them &
Google's no help so far.

HTH,

Twayne`
Re: who is changing dots into underscores in my variable names in REST? [message #169780 is a reply to message #169777] Sun, 26 September 2010 18:08 Go to previous message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Twayne wrote:
> In news:cdju96dvgbnmqm0br2t7n1ogkrnm8em6jq(at)mfesser(dot)de,
> Michael Fesser<netizen(at)gmx(dot)de> typed:
>> .oO(Twayne)
>>
>>> But both IE8 and FF will change a space to %20; I just
>>> tried it again. My site.com turns into my%20site.com. It
>>> happens with a lot of other characters too changing to
>>> their value instead of symbol.
>>
>> That's correct, because some characters like spaces for
>> example are not allowed in any part of a URI, so they have
>> to be encoded.
>>
>> Micha
>
> Exactly. Perhaps you can answer a question for me: The abiliity to use
> multiple dots; are multiple dots allowed in IPV 4 ? Or are they an IPV 6
> implementation? I though I had the papers on it but can't find them&
> Google's no help so far.
>

Aren't you conflating some things here? IPV6 and IPV4 are merely
Internet addressing standards, IPV6 makes provision for the :: notation
to shorten the IP address. Dotted names like blah.com are URLs or domain
names and are resolved using other protocols such as DNS, etc.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: What's in this cookie?
Next Topic: Re: Can anyone recommend a good debugger & IDE for PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 04:33:33 GMT 2024

Total time taken to generate the page: 0.02554 seconds