quotes in file names

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Balaskas Evaggelos

    quotes in file names

    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,
    -ebal
  • Noodle

    #2
    Re: quotes in file names

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





    Balaskas Evaggelos wrote:
    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,
    -ebal

    Comment

    • Balaskas Evaggelos

      #3
      Re: quotes in file names

      Noodle wrote:
      You could use the htmlspecialchar s function to convert the quotes to
      " for browser display.
      >

      >
      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.

      Comment

      • Noodle

        #4
        Re: quotes in file names


        Balaskas Evaggelos wrote:
        Noodle wrote:
        You could use the htmlspecialchar s function to convert the quotes to
        " for browser display.

        >
        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.
        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:

        <?php
        if ($handle = opendir('.')) {
        echo '<ul>';
        while (false !== ($file = readdir($handle ))) {
        echo '<li>' . htmlspecialchar s($file) . '</li>';
        }
        echo '</ul>';
        closedir($handl e);
        }
        ?>

        Comment

        Working...