[TYPO3] Typolink parsing links incorrectly

Bernd Wilke xoonsji02 at sneakemail.com
Fri Feb 23 23:55:03 CET 2007


On Fri, 23 Feb 2007 13:45:49 -0800, Christopher Torgalson wrote
with subject "Re: [TYPO3] Typolink parsing links incorrectly":

> Hi,
> 
> On 2/23/07, Bernd Wilke <xoonsji02 at sneakemail.com> wrote:
> > On Fri, 23 Feb 2007 17:17:40 +0100, Florian Schaeffer wrote
> > with subject "Re: [TYPO3] Typolink parsing links incorrectly":
> >
> > > Hello Sara,
> > >
> > > > Typo3 has (for the last day or so) started changing links (added through
> > > > 'make link' using htmlareaRTE)
> > > >
> > > > from
> > > > index.php?id=61&L=1 to ?id=61&amp;L=1
> > > >
> > > > Does anyone know which TSObject lib I need to change to stop it changing
> > > > the & to &amp;
> > > >
> > > > Its something to do with the htmlspecialchars property I assume.
> > >
> > > actually this is the correct behaviour to be XHTML compliant, as a &
> > > must be escaped in XHTML by &amp;
> > > Every browser is fine with this, so nothing to worry about....
> >
> > caveeat: Javascript doesn't like it!
> > for every URL used in Javascript you must translate it back.
> 
> 
> That's odd. I've never seen any problems with html entities in js. For
> example, in the following sample, js both displays the link correctly
> and follows it to the correct location:
> 
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
> 	<title>JS Link Test</title>
> 	<script type="text/javascript">
> 		function readAndRelocate(id) {
> 			var testLinkLocation = document.getElementById(id).href;
> 			var decision = confirm("Follow the link?\n[" + testLinkLocation + "]");
> 			
> 			if (decision) {
> 				window.location = testLinkLocation;
> 			} else {
> 				return;
> 			}
> 		}
> 		
> 		window.onload = function() {
> 			readAndRelocate('foo');
> 		}
> 	</script>
> </head>
> <body>
> 	<p><a href="http://www.google.ca/search?hl=en&amp;q=typolink&amp;btnG=Search&amp;meta="
> id="foo">Search for typolink</a></p>
> </body>
> </html>
> 
> 
> Can you elaborate about the problems you're referring to?

in your example the URL is generated inside the javascript.
I refer to the output of typo3 if you use a image with 'click to
enlarge'-link.

the output is soemthing like:
<a href="#"
onclick="vHWin=window.open('index.php?id=200&L=0','FEopenLink','width=1040,height=750');vHWin.focus();return
false;"><img src="fileadmin/preview.gif" alt="" align="right" border="0"
height="117" width="80"></a>
(I think this is the output of a "link in a new window" generated with rte)

here the URL is hardcoded in javascript and should read 
onclick="vHWin=window.open('index.php?id=200&amp;L=0','FEopenLink','width=1040,height=750');vHWin.focus();return
false;"
for correct XHTML. The ampersand has to be coded in any HTML-paramter.
Giving javascript this URL, you get valid XHTML, but only errors from
javascript.

Bernd
-- 
http://www.bernd-wilke.net


More information about the TYPO3-english mailing list