#31923 [NEW]: 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 00:59:36 +0000 |
| Subject: | #31923 [NEW]: file_get_contents() does not accept urls containing hypen period "-." | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-73823@lists.php.net to get a copy of this message | ||
From: mike-bugs dot php dot net at webheat dot co dot uk
Operating system: Linux
PHP version: 4.3.10
PHP Bug Type: Filesystem function related
Bug description: file_get_contents() does not accept urls containing hypen period "-."
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 bug report at http://bugs.php.net/?id=31923&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31923&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31923&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31923&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31923&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31923&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31923&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31923&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31923&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31923&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31923&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31923&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31923&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31923&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31923&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31923&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31923&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31923&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31923&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31923&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31923&r=mysqlcfg