#31923 [Bgs]: file_get_contents() does not accept urls containing hypen period "-."
| From: | mike-bugs dot php dot net at webheat dot co dot uk | Date: | Fri, 11 Feb 2005 23:02:21 +0000 |
| Subject: | #31923 [Bgs]: file_get_contents() does not accept urls containing hypen period "-." | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73906@lists.php.net to get a copy of this message | ||
ID: 31923
User updated by: mike-bugs dot php dot net at webheat dot co dot uk
Reported By: mike-bugs dot php dot net at webheat dot co dot uk
Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 4.3.10
New Comment:
If this is the case it does not explain why it works on two
machines(installed by me)and not on two otheres (installed by my
hosting company).
Btw, could you post a link to the RFD you are quoting from. I searched
on Google and found an RFC entitled "Who talks TCP?"
Thanks
Previous Comments:
------------------------------------------------------------------------
[2005-02-11 21:36:12] pollita@php.net
Please refer to RFC833 Appendix 1.
Hyphens may not appear at the start or end of a <label>.
gethostbyname() (Used by the network streams code among other parts of
PHP) treats this correctly according to RFC specification. Your
browser is simply more forgiving.
------------------------------------------------------------------------
[2005-02-11 08:53:38] mike-bugs dot php dot net at webheat dot co dot
uk
The urls are as an example, http://emdeeuk.deviantart.com/ does work.
The url that identified the problem is: http://mark-.deviantart.com/
A hyphen is valid in DNS.
------------------------------------------------------------------------
[2005-02-11 04:44:02] sniper@php.net
Those urls of yours don't work even in browser, why should they
magically work in PHP?? (is - valid in DNS anyway?)
------------------------------------------------------------------------
[2005-02-11 01:59:34] mike-bugs dot php dot net at webheat dot co dot
uk
Description:
------------
A script I created ( http://webheat.co.uk/forumbuddy.php ) takes a
username for the site DeviantArt.com which forms parts of the user's
section of the site. The url takes the form of:
http://USERID.deviantart.com/
The script grabs one or more pages by using the file_get_contents()
function.
Regardless of whether I use urlencode()/rawurlencode() and urldecode()
the file_get_contents() function chokes with the error as detailed
below.
This only happens when the userid ends in a hypen.
After some testing it seems to be that this is because the hyphen is
then next to a period "-."
This hyphen period combination causes an error regardless of where it
is placed in the user id.
This issue happens on my host's server but not on two other [Windows]
machines I've tested this code on.
The hosting company have gone through their php.ini file on my behalf
and whilst the file is not vanilla there are no differences that they
can see would affect this fuction.
Reproduce code:
---------------
The relevant code is as follows:
file_get_contents("http://emdeeuk-.deviantart.com");
//Doesn't work
file_get_contents("http://emdee-.uk.deviantart.com");
//Doesn't work
file_get_contents("http://emdeeuk.deviantart.com"); //Does work
The full code can be viewed here:
http://webheat.co.uk/forumbuddytest.php.txt
Expected result:
----------------
<a href="http://www.deviantart.com/deviation/14935843/">Dogs
on
Kites</a>
<a href="http://www.deviantart.com/deviation/14935312/">Welcome
to the
Rat Race</a>
<a href="http://www.deviantart.com/deviation/14934730/">Arc
de
Bishopsgate</a>
<a href="http://www.deviantart.com/deviation/14592356/">PLEASE
VOTE:
New Webheat.co.uk</a>
<a href="http://www.deviantart.com/deviation/14586143/">Docklands
Sunbathing</a>
<a href="http://www.deviantart.com/deviation/14556463/">Slide
PSP8
Frame</a>
<a href="http://www.deviantart.com/deviation/14556193/">Whitechapel
Horse</a>
<a href="http://www.deviantart.com/deviation/14521593/">Action
Squirrel</a>
<a href="http://www.deviantart.com/deviation/14520802/">Beady
Eye of
the Plottin Drake</a>
<a href="http://www.deviantart.com/deviation/14485015/">Light
House
II</a>
<a href="http://www.deviantart.com/deviation/14377961/">Polaroid
Photo
Frames</a>
<a href="http://www.deviantart.com/deviation/14217085/">Now
where's the
Sphinx?</a>
<a href="http://www.deviantart.com/deviation/14213953/">Something
in
the Aer</a>
<a href="http://www.deviantart.com/deviation/14125157/">I
Sea
Gulls</a>
<a href="http://www.deviantart.com/deviation/14124660/">Coots
really
get my Goose</a>
<a href="http://www.deviantart.com/deviation/13932181/">Spoonful
of
sugar</a>
<a href="http://www.deviantart.com/deviation/13757002/">Ugly
Emotion</a>
<a href="http://www.deviantart.com/deviation/13729717/">Light
House</a>
<a href="http://www.deviantart.com/deviation/13729376/">Ilm
Tree</a>
<a href="http://www.deviantart.com/deviation/13705596/">Only
ugly on
the inside</a>
<a href="http://www.deviantart.com/deviation/13639781/">Lava
Lamponians</a>
<a
href="http://www.deviantart.com/deviation/13597782/">Generations</a>
<a href="http://www.deviantart.com/deviation/9434166/">Flame
Mobile
Wallpaper</a>
<a href="http://www.deviantart.com/deviation/9421010/">Flame
Body Work
Wallpaper</a>
Actual result:
--------------
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo
failed: Name or service not known in
/home/webheat/public_html/forumbuddytest.php on line 6
Warning:
file_get_contents(http://USER-.deviantart.com/gallery/?view=3&order=5&limit=24&offset=0):
failed to open stream: Permission denied in
/home/webheat/public_html/forumbuddytest.php on line 6
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31923&edit=1