Apache OpenOffice (AOO) Bugzilla – Issue 10928
Link to index.html in a web page does not work
Last modified: 2014-05-15 08:26:02 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
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.
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.
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
Reassigned to ES
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.
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.
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:///".
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.
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.
.
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.
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.
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.
Asignee back to list