LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2006, 06:12 AM   #1
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Rep: Reputation: 30
html relative links


I am writing code which interprets html links in C.
My query relates to some html I have found in the big bad world.

If you look at the html source code for the page www.hosting-review.com/ it has a link of <a href="../../preferredsites/main.shtml>.

But the current page is "/". so how can you reference "../../" ???

I checked for a "base" element ,but I couldn't see any in the html source.

I perused the relavant rfc's but from what I can gather relative links should always be referenced in relation to the current document unless a base document has been stated ?!?!

Am I missing something?

Thnks in advance
 
Old 05-03-2006, 06:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well these paths are relative to the server, so that will simply go up to a higher level than the documentroot and then back into another directory. it's fairly ugly, but valid. ideally your web server permissions would be configure to protect yourself from external attacks trying to reach outside of the documentroot, but if you want to do otherwise then that's the webmasters perogative i guess.
 
Old 05-03-2006, 07:01 AM   #3
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Original Poster
Rep: Reputation: 30
Thanks 4 reply.
Part of my program is a http\1.1 implementation.

When i do..

Code:
 get(www.hosting-review.com/../../preferredsites/main.shtml;
the server sends back a http 400 error stating an invalid request.

but if I do
Code:
get(www.hosting-review.com/preferredsites/main.shtml);
.

I get the http 200 status and the document is served ok.

Should I re-chek my code???.

From what you are saying the "ugly link" should work should it not.

thanks again.
 
Old 05-03-2006, 07:39 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
yes it should serve, but maybe your source you're looking at is possibly serving from that depth in the first place.. could it be an iframe coming from a different directory or something?
 
Old 05-03-2006, 08:35 AM   #5
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Original Poster
Rep: Reputation: 30
I don't believe it was an Iframe,maybe I typed the url wrong at the command line ???

Mozilla handles the link ok,so I'm missing soemthing.

My program is a spider so I would want to translate the relative path to its full url so that it can be indexed,but the full url is hidden from the user in this case?!!

I don't know...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
html hyper links slzckboy Programming 3 04-06-2006 04:49 PM
html links from various sources rblampain Programming 2 11-24-2005 10:32 PM
Symbolic Links, directories, and relative paths (../). Can it be done? jimwillsher Linux - Newbie 1 03-11-2005 05:27 PM
HTML links in signatures? BajaNick LQ Suggestions & Feedback 3 12-20-2004 02:32 AM
Can't open html links in email Glock Shooter Linux - Newbie 1 06-04-2002 12:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration