HTML Problem

Discussion in 'HTML' started by CyberDroog, Jul 14, 2005.

  1. CyberDroog

    CyberDroog Guest

    At least I think it is... I have been playing with HttpFileServer
    v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    templates.

    One of the template has a problem with file names that contain a single
    quote character. The forum for the software doesn't seem to have much
    traffic, so maybe someone here can see what the problem is and how to fix
    it.

    An example line from the code to display a file name: <tr class="mout"
    onmouseover="this.className='mover'" onmouseout="this.className='mout'"
    onclick="location.href='%item-url%'">

    The part: onclick="location.href='%item-url%' seems to be the problem since
    it is surrounded by single quotes. When it comes across a folder name such
    as: CD's, that seems to translate in the code to 'CD's', and the code
    chokes. Clicking the link does nothing, and reloading the file list can
    produce an "Error expecting ;" for every file or folder name that contains
    a single quote.

    Is there a simple way to fix this?

    --
    MONDAY, n. In Christian countries, the day after the baseball game.

    - Ambrose Bierce
    CyberDroog, Jul 14, 2005
    #1
    1. Advertising

  2. CyberDroog

    Martin Jay Guest

    In message <>, CyberDroog
    <> writes
    >At least I think it is... I have been playing with HttpFileServer
    >v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    >templates.


    [Snip]

    >The part: onclick="location.href='%item-url%' seems to be the problem since
    >it is surrounded by single quotes. When it comes across a folder name such
    >as: CD's, that seems to translate in the code to 'CD's', and the code
    >chokes. Clicking the link does nothing, and reloading the file list can
    >produce an "Error expecting ;" for every file or folder name that contains
    >a single quote.


    It's probably getting upset about the ' in CD's.

    >Is there a simple way to fix this?


    Rename the directory so that is doesn't contain a ' in the name. Maybe
    to CDs instead.
    --
    Martin Jay
    Phone/SMS: +44 7740 191877
    Martin Jay, Jul 14, 2005
    #2
    1. Advertising

  3. CyberDroog

    CyberDroog Guest

    On Thu, 14 Jul 2005 18:14:01 +0100, Martin Jay <>
    wrote:

    >In message <>, CyberDroog
    ><> writes
    >>At least I think it is... I have been playing with HttpFileServer
    >>v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    >>templates.

    >
    >[Snip]
    >
    >>The part: onclick="location.href='%item-url%' seems to be the problem since
    >>it is surrounded by single quotes. When it comes across a folder name such
    >>as: CD's, that seems to translate in the code to 'CD's', and the code
    >>chokes. Clicking the link does nothing, and reloading the file list can
    >>produce an "Error expecting ;" for every file or folder name that contains
    >>a single quote.

    >
    >It's probably getting upset about the ' in CD's.


    Yes, that is what I said is causing the problem.

    >>Is there a simple way to fix this?

    >
    >Rename the directory so that is doesn't contain a ' in the name. Maybe
    >to CDs instead.


    Changing every file name on my system which contains a single quote
    character isn't going to happen. It's just too common, especially in my
    MP3 folders.

    --
    FAMOUS, adj. Conspicuously miserable.

    - Ambrose Bierce
    CyberDroog, Jul 14, 2005
    #3
  4. CyberDroog wrote:

    > Changing every file name on my system which contains a single quote
    > character isn't going to happen. It's just too common, especially in my
    > MP3 folders.


    I'm not sure what OS you're running but I wouldn't have thought batch
    renaming of files would be too difficult. I'm on Linux myself and I should
    imagine it's just a one-liner at the command prompt. (but don't ask me
    what).

    regards,
    --
    Robert
    http://brightonfixedodds.net
    Robert Frost-Bridges, Jul 14, 2005
    #4
  5. CyberDroog

    Stan McCann Guest

    CyberDroog <> wrote in
    news::

    > At least I think it is... I have been playing with HttpFileServer
    > v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    > templates.
    > The part: onclick="location.href='%item-url%' seems to be the
    > problem since it is surrounded by single quotes. When it comes
    > across a folder name such as: CD's, that seems to translate in the
    > code to 'CD's', and the code chokes. Clicking the link does
    > nothing, and reloading the file list can produce an "Error expecting
    > ;" for every file or folder name that contains a single quote.
    >
    > Is there a simple way to fix this?
    >


    This is off topic for this group as it is not an HTML issue.

    With that said, your fix is to rename the directories. Although some
    OSes will let you get away with it, ' is not a valid character for file
    names on some OSes. There are many symbols that are valid, but a good
    rule of thumb to go by is to use letters, numbers, -, _ and . only.
    Stick to those and you will rarely, if ever, have file name problems.

    --
    Stan McCann "Uncle Pirate" http://stanmccann.us/pirate.html
    Webmaster/Computer Center Manager, NMSU at Alamogordo
    http://alamo.nmsu.edu/ There are 10 kinds of people.
    Those that understand binary and those that don't.
    Stan McCann, Jul 14, 2005
    #5
  6. CyberDroog

    CyberDroog Guest

    On Thu, 14 Jul 2005 20:12:11 GMT, Robert Frost-Bridges
    <> wrote:

    >CyberDroog wrote:
    >
    >> Changing every file name on my system which contains a single quote
    >> character isn't going to happen. It's just too common, especially in my
    >> MP3 folders.

    >
    >I'm not sure what OS you're running but I wouldn't have thought batch
    >renaming of files would be too difficult. I'm on Linux myself and I should
    >imagine it's just a one-liner at the command prompt. (but don't ask me
    >what).


    I didn't mean to say it was difficult. I do batch renames all the time
    because I'm kind of obsessive/compulsive about consistent and well-ordered
    file names.

    I meant to say that it's something I just won't do. A single quote
    character is a legal character in a file name and I don't have any
    intention of not using them because a bit of HTML can't deal with it.
    I have other templates for HFS that work just fine.

    I was just curious about the bit of code I posted. To fix it would, I
    gather, require escaping the single quote characters that may appear in
    file names. That's easy if the file names are explicitly defined. But
    this is a variable - the code doesn't know if a file name will have a
    single quote character, or how many of them.

    --
    I love deadlines. I love the whooshing sound they make as they fly by.

    - Douglas Adams
    CyberDroog, Jul 15, 2005
    #6
  7. CyberDroog

    CyberDroog Guest

    On 14 Jul 2005 13:15:58 -0700, Stan McCann <> wrote:

    >CyberDroog <> wrote in
    >news::
    >
    >> At least I think it is... I have been playing with HttpFileServer
    >> v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    >> templates.
    >> The part: onclick="location.href='%item-url%' seems to be the
    >> problem since it is surrounded by single quotes. When it comes
    >> across a folder name such as: CD's, that seems to translate in the
    >> code to 'CD's', and the code chokes. Clicking the link does
    >> nothing, and reloading the file list can produce an "Error expecting
    >> ;" for every file or folder name that contains a single quote.
    >>
    >> Is there a simple way to fix this?
    >>

    >
    >This is off topic for this group as it is not an HTML issue.
    >
    >With that said, your fix is to rename the directories. Although some
    >OSes will let you get away with it, ' is not a valid character for file
    >names on some OSes. There are many symbols that are valid, but a good
    >rule of thumb to go by is to use letters, numbers, -, _ and . only.
    >Stick to those and you will rarely, if ever, have file name problems.


    On what OSes would a single quote be an illegal character in a file name?
    These directories are on a Win2k3 Server, but I haven't had any problems
    accessing them with any other version of Windows, or DOS, or Mandriva
    Linux. Though with Linux I am using KDE. I can't recall if I've tried
    playing with such a file on the command line.

    Doesn't matter though. I like them the way they are. ;)

    The whole matter is academic really. I was just fiddling with a template
    to see how it works and to figure out what to tweak to change features,
    appearance, etc. As you pointed out, I know so little about it that I
    wasn't aware that that portion of the code wasn't HTML. What is it,
    javascript?

    I suppose I can just dig in and rearrange the code such that the
    %item-name% is no longer nested in quotes. That works fine in other
    templates, though maybe because they are pure HTML.

    --
    "'Stupid' means one thing: threatening to the interests of the Democratic
    Party. The more Conservative the Republican, the more vicious and
    hysterical the attacks on his intelligence will be."

    - Ann Coulter
    CyberDroog, Jul 15, 2005
    #7
  8. CyberDroog

    rf Guest

    CyberDroog wrote:

    > The part: onclick="location.href='%item-url%' seems to be the problem

    since
    > it is surrounded by single quotes.


    onclick='location.href="%item-url%";' ?

    Cheers
    Richard.
    rf, Jul 15, 2005
    #8
  9. CyberDroog

    CyberDroog Guest

    On Fri, 15 Jul 2005 06:43:43 GMT, "rf" <@invalid.com> wrote:

    >CyberDroog wrote:
    >
    >> The part: onclick="location.href='%item-url%' seems to be the problem

    >since
    >> it is surrounded by single quotes.

    >
    >onclick='location.href="%item-url%";' ?


    That just changes the error message (unterminated string literal).

    I've been thinking that, since %item-name% is a variable in which there is
    no telling whether is contains a single quote, or how many, maybe I need a
    function to search through it and replace all instance of a single quote
    with an escape sequence.

    --
    One of the annoying things about believing in free will and individual
    responsibility is the difficulty of finding somebody to blame your problems
    on. And when you do find somebody, it's remarkable how often his picture
    turns up on your driver's license.

    - P.J. O'Rourke
    CyberDroog, Jul 15, 2005
    #9
  10. CyberDroog

    Neredbojias Guest

    With neither quill nor qualm, CyberDroog quothed

    > I've been thinking that, since %item-name% is a variable in which there is
    > no telling whether is contains a single quote, or how many, maybe I need a
    > function to search through it and replace all instance of a single quote
    > with an escape sequence.


    A regular expression replace would be a cinch.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Jul 15, 2005
    #10
  11. CyberDroog

    kchayka Guest

    CyberDroog wrote:
    >
    > The part: onclick="location.href='%item-url%' seems to be the problem since
    > it is surrounded by single quotes. When it comes across a folder name such
    > as: CD's


    If you insist on using quote marks in file or folder names, you should
    url-encode them in the HTML, i.e.

    item-url = "CD%27s"

    Do this with any character other than letters, numbers, dashes,
    underscores or periods, and you won't have any browser troubles.

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
    kchayka, Jul 15, 2005
    #11
  12. CyberDroog

    CyberDroog Guest

    On Fri, 15 Jul 2005 11:09:14 -0500, kchayka <> wrote:

    >CyberDroog wrote:
    >>
    >> The part: onclick="location.href='%item-url%' seems to be the problem since
    >> it is surrounded by single quotes. When it comes across a folder name such
    >> as: CD's

    >
    >If you insist on using quote marks in file or folder names, you should
    >url-encode them in the HTML, i.e.
    >
    >item-url = "CD%27s"
    >
    >Do this with any character other than letters, numbers, dashes,
    >underscores or periods, and you won't have any browser troubles.


    The problem is that this is a dynamic process. The code simply reads any
    folder/file tree it is pointed at.



    --
    To make an apple pie from scratch, you must first invent the universe.
    CyberDroog, Jul 15, 2005
    #12
  13. CyberDroog

    Martin Jay Guest

    In message <>, CyberDroog
    <> writes
    >At least I think it is... I have been playing with HttpFileServer
    >v2.0beta23 (http://www.rejetto.com/sw/) along with some user created
    >templates.


    >One of the template has a problem with file names that contain a single
    >quote character. The forum for the software doesn't seem to have much
    >traffic, so maybe someone here can see what the problem is and how to fix
    >it.


    >An example line from the code to display a file name: <tr class="mout"
    >onmouseover="this.className='mover'" onmouseout="this.className='mout'"
    >onclick="location.href='%item-url%'">


    >The part: onclick="location.href='%item-url%' seems to be the problem since
    >it is surrounded by single quotes. When it comes across a folder name such
    >as: CD's, that seems to translate in the code to 'CD's', and the code
    >chokes. Clicking the link does nothing, and reloading the file list can
    >produce an "Error expecting ;" for every file or folder name that contains
    >a single quote.


    If you're willing to use Javascript, as you appear to be, there may be a
    solution.

    Assign %item-url% to a variable;

    replace ' with %27 in the variable's contents;

    then, replace %item-url% in onclick="location.href='%item-url%' with the
    new variable name.
    --
    Martin Jay
    Martin Jay, Jul 15, 2005
    #13
  14. CyberDroog

    kchayka Guest

    CyberDroog wrote:
    > On Fri, 15 Jul 2005 11:09:14 -0500, kchayka <> wrote:
    >
    >>If you insist on using quote marks in file or folder names, you should
    >>url-encode them in the HTML

    >
    > The problem is that this is a dynamic process. The code simply reads any
    > folder/file tree it is pointed at.


    No excuse. PHP has a built-in function that does this, as do other
    languages. And then there are always regular expressions...

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
    kchayka, Jul 15, 2005
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    7,067
  2. Mitchua
    Replies:
    1
    Views:
    7,032
    Ice Demon
    Jul 15, 2003
  3. Merek
    Replies:
    0
    Views:
    1,937
    Merek
    Dec 3, 2003
  4. karthikeyavenkat
    Replies:
    2
    Views:
    554
    Bryce
    Mar 17, 2005
  5. Adam Akhtar
    Replies:
    9
    Views:
    500
    Florian Gilcher
    Aug 16, 2008
Loading...

Share This Page