Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 11 of 11

This is a discussion on Errant "amp;" in HTML code in the Shared & Semi-Dedicated forum
I'm having a problem in File Manager. Every time I open an .html page in the "edit page" function, these characters (without the quotes) are ...

  1. #1
    JPC Member
    Join Date
    Mar 2002
    Location
    Alfred, NY
    Posts
    8

    Question Errant "amp;" in HTML code

    I'm having a problem in File Manager. Every time I open an .html page in the "edit page" function, these characters (without the quotes) are added after every occurrence of & (ampersand) in the html code: "amp;"

    If I opened and saved a page in the editor three times, eveywhere an & appears on the page, the following appears in the code:

    &

    If I open the page 30 times, amp; will appear 30 times!!

    This doesn't seem to be a problem in text lines, as the extra code is ignored, but when the & is in javascript, or link addresses, or in alt text for images, it either appears or mucks things up pretty good.

    Is anyone else out there experiencing this, and is there a way to make the server stop doing this (I can remove the extra code before saving every time, but it's pretty annoying and I'd like for it not to appear in the first place!)?

    I know that "&" is the character entity for an ampersand, so I'm assuming the server is changing every occurrence on each page from the ascii character to its character entity, but I don't want it to do this!

    Any help or information would be appreciated. Thanks!

  2. #2
    JPC Senior Member
    Join Date
    Sep 2001
    Posts
    50
    "&" is the HTML code for an ampersand. Just as © is the little copyright symbol and   is a non-breaking space. The editor is translating it for you. Leave it as "$amp;". It'll show in the user's browser as an ampersand.

    -Al
    --
    Alien Heat - Affordable Web Hosting and Design
    http://www.AlienHeat.com

  3. #3
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    How about trying some good ol' ASCII, like & (alt-38) or & # 38 ; (minus the spaces)? Sheesh, I can't even get the code to display here, it works so good!

    ◙♀¶§↓ö¥, blah, blah, blah. Anyone old school programmers here? You know what I'm talking about?

    Reply to this message, using the quote feature, and look at the code:
    Code:
     &
    You'll see what I mean...
    Last edited by Vin DSL; 01-10-2004 at 09:48 PM.
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  4. #4
    JPC Member
    Join Date
    Mar 2002
    Location
    Alfred, NY
    Posts
    8

    Unhappy Thanks Al & Vin DSL

    But I know how to MAKE the & appear as an & in the browser if I want it to - I do most of my html as "old school programming" - in this case, the Apache server seems to be altering my code in my pages each time I open the pages in the online page editor function.

    I'll try to give you a more specific example:

    Let's say I open an html document in the online page editor from the file manager in my control panel.

    Let's say I type the following lines on the page (I've replaced the html code brackets with perentheses for display here, for obvious reasons) - the first is a line from an image map, the second is a line from some javascript in the page (a counter) - the way you see each of these samples here is the way the code appears in the editor:

    -----------------------------------

    (AREA SHAPE=RECT COORDS="389,159,691,191" HREF="http://www.xxxxx.org/cbl.html" ALT="CONSTITUTION & BY-LAWS")


    (!--
    DeleteCookie("xxxx_pagexxxx_555");
    var referrer=escape(top.document.referrer);
    document.write('(img border="0" height="1" width="1" alt="xxxxx.com" src="http://www.xxxxxx.com/cgi/xxxxx.cgi?a=9999&p=555&g=9&r=' + referrer + '")');
    //--)

    -----------------------------------------


    NOW - I save the page and the code stays as I've written it, and the page works fine, but the next time I open the page in the online editor, the amp; is added after each ampersand, thus:

    -----------------------------------

    (AREA SHAPE=RECT COORDS="389,159,691,191" HREF="http://www.xxxxx.org/cbl.html" ALT="CONSTITUTION & BY-LAWS")


    (!--
    DeleteCookie("xxxx_pagexxxx_555");
    var referrer=escape(top.document.referrer);
    document.write('(img border="0" height="1" width="1" alt="xxxxx.com" src="http://www.xxxxxx.com/cgi/xxxxx.cgi?a=9999&p=555&g =9&r=' + referrer + '")');
    //--)

    -----------------------------------------

    Each time I open the html document in the online editor, the server automatically adds amp; after each ampersand - if I opened the sample page here four times in the editor (like with four different edits on four different days), I'd end up with:

    -----------------------------------

    (AREA SHAPE=RECT COORDS="389,159,691,191" HREF="http://www.xxxxx.org/cbl.html" ALT="CONSTITUTION & BY-LAWS")


    (!--
    DeleteCookie("xxxx_pagexxxx_555");
    var referrer=escape(top.document.referrer);
    document.write('(img border="0" height="1" width="1" alt="xxxxx.com" src="http://www.xxxxxx.com/cgi/xxxxx.cgi?a=9999&p=5 55&g=9&a mp;amp;r=' + referrer + '")');
    //--)

    -----------------------------------------

    Once the additional code gets added, the javascript no longer functions properly, and the alt text appears with all the extra text in it and looks stupid.

    How can I make the server STOP adding this after each & ???

  5. #5
    Pointy Stick Expert
    Join Date
    Nov 2002
    Posts
    143

    Re: Thanks Al & Vin DSL

    Originally posted by gacsm
    How can I make the server STOP adding this after each & ???
    Sounds like yet another CPanel bug - appears the online editor isn't parsing correctly when it opens the file.

    But I gotta ask - why would you want to use that editor? If you don't want to download locally and edit, why not just use one of the shell editors? They're all much faster and more powerful...

    Bill

  6. #6
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Yep, exactly what I was going to say...

    (Sorry for the rude smilie - blame it on JagPC - too tempting)

    This situation reminds me of the BBS software they use here. It automatically parses URL's, even in things surrounded by code tags. If you forget to turn off the parse feature and preview a message that you DON'T want parsed, you're screwed. Sounds like that cPanel editor does the same thing.

    My HTML editor of choice is HomeSite (been using it for years), but there are dozens of others out there now that will work almost as good. I'm with wgiese on this one. Find a shell editor that you like and give up on that cPanel dog...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  7. #7
    JPC Member
    Join Date
    Mar 2002
    Location
    Alfred, NY
    Posts
    8

    Lightbulb Thanks folks

    (Just got back in town!)

    That's what I figured - the thing is adding the extra code and nothing much can be done!

    By shell editor, you mean software that will automatically pull the pages from the net when opened, then publish them back to the net when saved?

    Do any of you have a recommended Shell Editor?

    I don't use the Cpanel editor for major stuff - just quick one-liner updates, link changes, etc . .

    I have an old version of Homesite (OLD - version 1.2 I think - from before Macromedia purchased the company!) that I've used and liked - but it doesn't appear to be able to act as a shell editor (if I've got what a shell editor is right). Maybe a newer version does?

    ______________

    BTW - this "bug" is wierd - it only affects files called .html - if the opened file is a .txt or .tpl or whatever else (non-HTML), then the code is left untouched. Ah well . . .

    Do you all think it would be worth opening a support ticket to see if they can fix this - especially for others who use the Cpanel editor exclusively?

  8. #8
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    NO, a shell editor is an editor that you use in the Unix shell (SSH). Basically, you get an SSH client (which works in a similar manner to telnet, but encrypts data for security) and use that to log in to your site. Once you're in, you'll have a Unix prompt (similar to the DOS Prompt in Windows). From there you can type <editor name> <filename> to edit the file. Common editors are vi (which has picked up the nickname "virtually impossible," it's very difficult to use, but very powerful), emacs (a little easier), and pico (very easy to use but not as powerful as vi). For most general purpose editing pico will work quite well.

    The easiest SSH client to use that I know of is PuTTY, which can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/
    (Note: you'll probably also have to open a support ticket asking for SSH access to your account. They'll usually get you set up within minutes and there is no charge for the service.)

    Another option, which is more in line with your impression is a program called Crimson. It's a basic Windows text editor with features like syntax highlighting and spell checking. One nice feature of it is that it lets you read and save files from/to an FTP site. I use it on a site that I maintain where I need to be able to quickly post announcements on the home page. I don't have SSH or telnet access to the site, so I use Crimson to make the edits. You can get Crimson at http://www.crimsoneditor.com/.

    If you are making on the fly edits, make sure that you are making regular backups of your site. Personally, I try to do all of my development locally and then upload it later (with the excaption of thoise announcements, which I don't care about if they get lost). That way I always have a mirror of the site ready to go in the event of a server crash or some other catastrophe.

    Hope this helps you out.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  9. #9
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Just noticed the notes you put at the bottom of your post.

    First, it makes sence that it would only change those characters in HTML files becasue they are HTML entities. & amp ; has no meaning in any files other than html files (or sometimes XML files). The CP editor probably runs your code through something like the PHP function htmlspecialchars() to convert these things.

    Second, I'm not sure how many people out there use the CP editor exclusively. I'm sure there are a few, but since you are the first person to bring this issue up, I can't imagine there are too many (except maybe a few non-power users who never use JavaScript or anything other than straight HTML). I'm not sure how much control JPC has over the inner-workings of CP. They've had difficulties fixing problems in the past and usually just have to wait for the CP team to release a fix.

    Maybe, as a temporary solution, you could rename the files to something like .txt, make the changes, and then rename them to .html again. It would be a total PITA, I realize, but it might work. Personally, though, I'd go with one of my suggestions from my first post.

    --Jason
    Last edited by jason; 01-16-2004 at 06:46 AM.
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  10. #10
    JPC Member
    Join Date
    Mar 2002
    Location
    Alfred, NY
    Posts
    8

    Thumbs up Thanks

    Thanks all for the help!

    And Jason - I've downloaded some of the stuff you pointed me to, and am going to try some of it out over the next few weeks. SSH seems like the way to go.

    I also found an FTP Publish function in the newest version of Composer, which seems like it could be good for those quick edits.

    Thanks again!
    Last edited by gacsm; 01-18-2004 at 05:20 AM.

  11. #11
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775

    Re: Thanks

    Originally posted by gacsm
    SSH seems like the way to go...
    Absolutely, positively, without a doubt!!! It's one of the things YOU are paying for - one of the biggest reasons to host here IMHO. Most mass webhosters don't even allow shell access. Anyone NOT taking advantage of the shell feature on JagPC is a fool...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •