Issue 10928 - Link to index.html in a web page does not work
Summary: Link to index.html in a web page does not work
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: 643C
Hardware: PC Windows XP
: P4 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2003-01-25 02:30 UTC by kelvine
Modified: 2014-05-15 08:26 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kelvine 2003-01-25 02:30:38 UTC
Hi,

Using HTML Editor I create a simple Home Page and save the file as index.html.

Then if I insert a link to the page index.html this does not work.  It has not 
worked since version 1 of OpenOffice.org and maybe before this.

To get around this I always use a graphic or java applet to go to the home 
page or index.html on a web page bu this is a little inconvenient.

The steps to repeat this problem is simple.
Create a new HTML document.
Type in "This is my Home page."
Save the document as index.html
Now click on the Hyperlink dialogue button.
In Path find the index.html file just created.
In Text type in "Home Page"
Click on Apply and Close

The html code generated is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-
1252">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 643  (Win32)">
	<META NAME="CREATED" CONTENT="20030125;13193215">
	<META NAME="CHANGED" CONTENT="20030125;13230024">
</HEAD>
<BODY LANG="en-US">
<P>This is my home page</P>
<P><A HREF="">Home Page</A></P>
</BODY>
</HTML>

As you can see there is no index.html in between the HREF quotes and I think 
there should be.

It would be appreciated if this could be fixed.

Thanks,

Kelvin
Comment 1 kelvine 2003-01-25 03:00:27 UTC
Hi,

Me again.  I just tested this same problem which has continued to 
haunt me for months.
I followed my own instructions and everything worked fine.  I could 
not believe it.  I repeated it three times and everything worked 
fine.

So I checked again.
This problem only seems to happen if the index.html is just being 
created.  That is a new folder with no existing files in it.

I deleted all the files in the folder where I saved the index.html 
and the problem starting occuring again.  Then I could not get an  
index.html link to work correctly again.

I hope this helps.  The problem is bit weird, but aren't all 
problems until you work out why it is happening.


Thanks Kelvin.
Comment 2 prgmgr 2003-06-14 20:18:20 UTC
Thank you for using and supporting OOo.

Duplicate on RH 9.0, OOo 1.0.3.1 & 1.1 Beta 2.

In summary, the HTML does not insert the proper URL in the <A> tag
when it refers to the same file.
Comment 3 kelvine 2003-06-16 04:41:51 UTC
Hi,

I noticed this issue was dropped in priority.  This is fine and 
thanks for looking at it.

However I would just like to point out the index.html is the first 
link which users are likely to use given it refers to the home page 
and is generally required on every site and every page.

Thus every user will consider the Html Editor does not work 
correctly with links and every user will need to work around the 
issue.

Just thought I would let you know this issue is more important than 
it looks.

Kelvin
Comment 4 h.ilter 2003-06-16 10:25:30 UTC
Reassigned to ES
Comment 5 eric.savary 2003-07-24 12:05:20 UTC
Reproducible: plus, if you switch one time from online layout to page
layout, the link changes fron
<A HREF="">
to
<A HREF="../{current_dir}">
Which point to the dir an not to the file.
Comment 6 michael.brauer 2003-08-27 11:14:38 UTC
MIB->SB: What happens is that the base URL is something like 
file:\\\test.html and the URL to make relative is file:\\\test.html.
INetURLObject::AbsToRel returns an empty string in this case. 
We either have to change this, or we have to set a base URL "file:\\\"
only. I'm not sure which solution is better. The base URL is
maintained in the SFX.
Comment 7 Stephan Bergmann 2003-08-27 12:59:06 UTC
SB->MIB:  You use backslashes ("file:\\\test.html") instead of forward
slashes ("file:///test.html"), but I assume that is just a typo.
INetURLObject::AbsToRel indeed returns an empty string when the base
URL and the absolute URL are identical.  This is the correct behaviour
(a URI reference that is just the empty string represents the current
document, see RFC 2396), so I would not want to change that---no idea
what else would break then.  I see three solutions, most preferred one
first:
1  Improve the calling code so that it can cope with an empty return
from AbsToRel.
2  Add an extra flag parameter to AbsToRel (or rather GetRelURL, as
AbsToRel is obsolete) indicating to not return an empty string for the
current document.
3  Change the base URL from "file:///test.html" to just "file:///".
Comment 8 michael.brauer 2003-08-28 08:23:47 UTC
Changing the calling code seems not be the best solution to me,
because the calling code should not know anything of URL processing.
So we may eitehr add a parameter to AbsTorel/GetRelURL or we may
change the base URL. I don't know whcih solution is better, So I let
it up to you to decide to change either AbsToRel/GetRelURL or ask SFX
to change the base URL.
Comment 9 Stephan Bergmann 2003-08-28 14:29:53 UTC
I would like to split this bug in two:
1  When saving to HTML a document that contains a link to itself, the
link is written out as an empty URI reference (<A href="">...).
2  When loading an HTML document that contains a link that is an empty
URI reference (<A href="">...), the link is made absolute so that it
points to the directory instead of the HTML document itself.

To 1:  As already described, I consider this correct behaviour; an
empty URI reference denotes the current document.  This is analogous
to a URI reference that has an empty URI and only a fragment (e.g., <A
href="#id">...), which denotes a given position in the current
document.  However, browsers seem to handle this inconsistently; take
the HTML document
+-----
  <HTML>
  <HEAD><TITLE>Test</TITLE></HEAD>
  <BODY>
  <H1 id="heading">Heading</H1>
  <P>Link to <A href="">self</A>.</P>
  <P>Link to <A href="#heading">heading</A>.</P>
  </BODY>
  </HTML>
+-----
Opening it with Mozilla 1.4 (on WinXP), both links are interpreted as
links into the current document.  But opening it with Internet
Explorer 6 (on WinXP), the <A href=""> link is interpreted as a link
to the directory, while the <A href="#heading"> link is interpreted as
a link into the current document; I consider this behaviour a bug of
Internet Explorer.
Only to work around the erroneous behaviour of browsers like Internet
Explorer, I could imagine to extend INetURLObject::GetRelURL (with an
extra flag?) so that it does not return empty strings.  If we want to
take this measure, I think it would be best to file a new issue for it.

To 2:  The reason a link <A href=""> is interpreted as a link to the
directory when loaded in OOo (analogous to the erroneous behaviour of
Intetnet Explorer!) is lines 1333--1344 of
sw/source/filter/html/htmlgrin.cxx 1.10:
  if( sHRef.Len() )
  {
      ASSERT( INetURLObject::GetBaseURL() == sBaseURL,
              "<A>: Base URL ist zerschossen" );
      sHRef = INetURLObject::RelToAbs( sHRef );
  }
  else
  {
      // Bei leerer URL das Directory nehmen
      INetURLObject aURLObj( aPathToFile );
      sHRef = aURLObj.GetPartBeforeLastName();
  }
probably together with the opening lines of INetURLObject::RelToAbs,
lines 5273--5275 of tools/source/fsys/urlobj.cxx 1.40:
  // Backwards compatibility:
  if (rTheRelURIRef.Len() == 0 || rTheRelURIRef.GetChar(0) == '#')
      return rTheRelURIRef;
I would suggest to fix the code in htmlgrin.cxx, and make that code
use INetURLObject::GetNewAbsURL (which has no "backwards
compatibility" special handling of empty strings) instead of the
deprecated INetURLObject::RelToAbs.  Doing so, make sure links like <A
href="#heading"> still work.
Comment 10 andreas.martens 2003-09-12 15:14:55 UTC
.
Comment 11 jogi 2003-10-22 08:38:48 UTC
.
Comment 12 michael.brauer 2003-10-30 08:58:22 UTC
To 1: I suggest to return "./<filename>" as relative link to the
document itself. Keeping an absolute URL to the document itself would
fix this bug, but introduce a new one, that is that a document
contains an absolute URL although relative URLs have been requested.
The workaround in any case is to export to disable relative URL for
the file system in Tools/Options/Load+Save/General.
To 2: The current behavior probably has been introduced to behave the
same as other browsers. We may turn it off, but whatever we do, we
will behave different than one or the other class of browsers. For
this reason I suggest o fix issue 1 only. It indirectly fixes 2 as well.
Comment 13 michael.brauer 2003-10-30 11:13:50 UTC
.
Comment 14 michael.brauer 2003-10-30 12:08:08 UTC
.
Comment 15 Stephan Bergmann 2003-11-03 09:08:57 UTC
Ok, for issue 1 ("When saving to HTML a document that contains a link
to itself, the link is written out as an empty URI reference") I will
add a flag to the appropriate INetURLObject function to create a
relative URL "./<filename>" instead of an empty one, to avoid
interoperability problems with broken browsers (like IE and OOo).
But note that this does *not* fix issue 2 ("When loading an HTML
document that contains a link that is an empty URI reference, the link
is made absolute so that it points to the directory instead of the
HTML document itself").  See my above comments about how to fix this.
Comment 16 utomo99 2007-06-24 05:03:43 UTC
Reminder from 2003
Please look at this again. Thanks

------- Additional comments from sb Mon Nov 3 09:08:57 +0000 2003 -------

Ok, for issue 1 ("When saving to HTML a document that contains a link
to itself, the link is written out as an empty URI reference") I will
add a flag to the appropriate INetURLObject function to create a
relative URL "./<filename>" instead of an empty one, to avoid
interoperability problems with broken browsers (like IE and OOo).
But note that this does *not* fix issue 2 ("When loading an HTML
document that contains a link that is an empty URI reference, the link
is made absolute so that it points to the directory instead of the
HTML document itself").  See my above comments about how to fix this.
Comment 17 Rainer Bielefeld 2014-05-15 08:26:02 UTC
Asignee back to list