Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Why "&" get converted into "_%26_" in the browser address field?

Quote Reply
Why "&" get converted into "_%26_" in the browser address field?
Hello All,
First I have implemented the addition of the ampersand "&" MOD: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001590.html .
Then I decided to implement the addition of special character instead: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001722.html .

Now, whenever a user submit his/her site from a category with ampersand in the cateogry name (say Arts & Humanities), then the category field does not get populated automatically, and the category shows as "_%26_" instead of "_&_" in the address location in the browser?!!

In addition, the add_error.html page comes corrupted because of this ampersand character in the category.
Can anyone tell me what I should do to fix this & --> %26 to get read correctly.
Also, I noticed one thing, when I telnet into my website (web2010 hosting), I can not type cd Arts_&_Humanities eventhough the directory is already exists. If I do so I get carbage such as Arts_ directory do not exist.

Please give my a hint or anything may help...
Regards..
Mark..


[This message has been edited by Edmk (edited March 07, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Did you add the second set of codes to the valid expression column for the Category field in the links.def file? That should solve your problem with regular expressions.

BTW: To access directories in your account, type in a wildcard character, *, after Arts, like the following:

Code:
cd Arts*

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hi Eliot,
I added the changes (as listed below) into the links.def file, bu I am still having the same problem (the field do not get populated if the category names contains an ampersand in its name when adding a site into the add form, and the add_error.html page comes with the entire list of all cateogries listed on one line above the category select menu in the error page).

- I have in links.def:

Category => [4, 'alpha', 0, 150, 1, '', '^[\w\d,\&\'\@/_-]+$'],

(is that what you meant with the second set of codes? I just added them but I get the same error as before. It did not change anything):


- and in category.def I have:

Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d,\&\'\@/_-]+$'],


- And In nph-build.cgi, under sub build_check_dir, I have:

my $chrs = quotemeta (",\&\'\@/_-");

- and also I have in the same file:

if ($dir !~ m,^[\w\d$chrs]+$,) {
&cgierr ("Invalid characters in category name: $dir. Must contain only letters, numbers, \,, \&, \', \@, _, / and -.");

Is this a problem with LINKS or with the UNIX hosting service.

P.S: yes wildcards worked fine on unix .. thank you..

Please let me know...
Regards...
Mark..





Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
This is not a bug with your hosting platform. It is a bug with the how you have used the Modification in your LINKS scripts.

I really don't know what else to tell you. Other than reverting back to the first Topic you found if that worked for you.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hi Eliot,
This gentlman has the same problem in this thread:

http://www.gossamer-threads.com/scripts/forum/resources/Forum11/HTML/001513.html

I reinstalled the first thread again but it did the same thing.
Basically, it is not populating the category with the right category field name if the category field has an amersand (&) in its name, and also still shows _%26_ in the browser field instead of _&_

Can you give me any sugustion or are you aware of anyone with the same problem; otherwise, I will be forced probably to convert over 6000 categories to use 'and' instead of '&'...

One more thing, I removed '^[\w\d/_&-]+$' from links.def and categroy.def and I still get the same problem. This means the '&' is not read from here or it is specified wrong in this field.
Can you please tell me what the right format for the '&' in the links.def ... etc

Thank you again for your help..
Regards..
Mark..


[This message has been edited by Edmk (edited March 08, 2000).]

[This message has been edited by Edmk (edited March 08, 2000).]

[This message has been edited by Edmk (edited March 08, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hello,
When I view the source of the generated HTML files (index.html), I find that the _&_ is showing as _%26_ in it, so I replaced the "%26" with "&" and everything worked perfectly.
So I was just wonderring if anyone knows any UNIX command that search for a particular string across of multiple directories, and replace all findings with another string??
Is that possible or do I have to write a C program for that?

P.S. Something like: grep but I wanted it to search and replace and save the changes ...

Thank you and regards...
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
All you have to do is a regular expression statement that will replace the %26 with & like the following:

Code:
$category_name =~ s/%26/\&/g;

Put this in the various sub-routines in the site_html_templates.pl where you want to change the %26 to &.

Hope this helps.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 12, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hi Eliot,
The approach you specified above (to place $rec{'Category'} =~ s/%26/\&/g ; ) is very good Wink but I was unable to locate where exactly I should place it.
I was thinking of putting it somewhere after the category name got generated (or printed) into the html file immediately. but the problem I do not know exactly where
this is happenning; or whether should it be
$category_name =~ s/%26/\&/g;
instead ... maybe.. so the category name in the html file will have a "&" instead of "%26" ... I have know idea..

I appreciate any comments you may give...
Regareds...
Mark

[This message has been edited by Eiad (edited March 12, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
You put it in the sub site_html_category in the site_html_templates.pl at the top before the loading of the template file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
I tried it but unfortunately it did not work.
I was thinking that the $rec{'Category'} =~ s/%26/\&/g; should be placed within a loop in order to have the entire html checked for occurancy of the %26, but where? that loop should be and what is its format.....!!

Thank you and regards..
Mark
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
No...it should not be in a loop. Similar regular expression codes have been used for other fields, including the Description field, to provide things like line breaking. The same should be used for replacing characters in fields with other characters.

At this point, I need to see an actual example of your problem. PLEASE link your LINKS directory in this topic.

BTW: I have edited my earlier Reply...Dumb me...The record hash for Category will not work since that is used for using the links.def.

What you need to use is $category_name NOT $rec{'Category'}. Same logic applies though for the rest of the codes.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 12, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hello Eliot,
I have already tried the $category_name =~ s/%26/\&/g; (as i mentioned in an earlier reply), but also it did not work.
Shouldn't be placed somewhere in the db_util.pl??? as this thread says:
http://www.gossamer-threads.com/...um3/HTML/005402.html

TO see an example, please visit my site (still way under construction... so watch your foot steps ) Smile
http://www.ArabBay.com
Please click on a category with "&" in its name like (News & Media), then look at the
Address field in your browser to see the ugly %26 , or you may view the HTML source if you like....

By the way, you really have a nice site.. Wink

Oh... one more thing, do you think that regular LINKS can handle my other site, or should I go SQL?? http://www.allnewspapers.com will I be able to maintain the same look in this site by using LINKS

Regards..
Mark

[This message has been edited by Edmk (edited March 13, 2000).]

[This message has been edited by Edmk (edited March 13, 2000).]
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Okay....now I see the problem and I believe I mentioned this before, you cannot define the & character differently than %26 in the URL that appears in the Location bar of the browser. & serves as a special character to separate arguments in query strings (URI).

It cannot be re-defined when it is used as a directory character. This is a cosmetic annoyance more than anything. It does not affect printing the & in your category pages, which is functioning fine.

About your other site...I will never visit it again, since it crashed three web browsers (Netscape 3.0, Netscape 4.07, and MIE 5.0) when I tried accessing it. If you have more than 5,000 records and the database size is more than 1 MG, then Yes, you will need LINKS SQL to run the site.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Great Eliot!!
Then we are back to point one...
Is there a command in UNIX that can search files for a specific string and replace the matched string with another one.. something like (grep...etc).? I want to use it every time I finish a build in order to change me the %26 to & in all the generated html files.

If you view the html source you would see the %26 in it, so it is just a matter of replacing this %26 with the & when the page is being built.

when I manually change the "%26" in the html files into "&" and ftp the pages back, then everything works perfectly.. so it must be easy to be able to change the %26 into & when the LINKS is generating the code....but where and how..?

Any suggustion..


Oh.. my..what happened, my other site crashing: AllNewspapers.com is been on the net for more almost two years with heavy traffics and never had anyone complained about it as of yet..(maybe they have no way of complaining since it crashes on them immediately) Smile
You probably have Java Support disabled on your browser or have a very high security level checked out.


Regards and thank you for your help
Mark

Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
How can I explain this more clearer? It is NOT possible to do what you want to do with the URL location in the Location Bar in the Browser! Let it be!

And about that site...NO..I have Java ENABLED in all those browsers, and it still crashes...definitely not a site I will visit in the future ever again.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Why "&" get converted into "_%26_" in the browser address field? In reply to
Hi Eliot,
I've already got the idea. I was really asking about a UNIX command in my previous reply which is not really related to the topic - my fault....
Anyway, thank you for your help and for your time.
I guess the only solution is to write a small script that search all html files for a specific string and replace it with the correct string everytime I run a build..

Thank you..
Mark.

[This message has been edited by Edmk (edited March 14, 2000).]