quotes in file names

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi to all,

I am developing a php web browser application.

But i have a problem.

I am listing with opendir but there are a lot of files with
quotes in their names.

example: News Letter for "ebal" today.html
(yes the above is only one file !!!)

When i browsing the files the listing doesn't show me the full name of  
my files, because of the quotes in the filename.

Any ideas?

php 4.4.4

best regards,

Re: quotes in file names

You could use the htmlspecialchars function to convert the quotes to
" for browser display.


Balaskas Evaggelos wrote:
Quoted text here. Click to load it

Re: quotes in file names

Noodle wrote:
Quoted text here. Click to load it

doesn't work,

because my special char is double quote "
and not 2 quotes ('') as opedir gives me.


The problem is in opendir function.
The opendir function read the filename with double quotes.
Do you thing this is a bug?

I changed the php.ini config about quotes but still the opendir
convert the double quotes in two quotes.

Re: quotes in file names

Balaskas Evaggelos wrote:
Quoted text here. Click to load it

You may not be using the function correctly. From the manual...

'"' (double quote) becomes '"' when ENT_NOQUOTES is not set ... If
ENT_QUOTES is set, both single and double quotes are translated and if
ENT_NOQUOTES is set neither single nor double quotes are translated.

The following code works for me:

   if ($handle = opendir('.')) {
       echo '<ul>';
       while (false !== ($file = readdir($handle))) {
           echo '<li>' . htmlspecialchars($file) . '</li>';
       echo '</ul>';

Site Timeline