I have recently built a new application for a corporate intranet using XPages. Everything works fine so far except one small thing .
The editors are using a standard Notes application to edit the content. From time to time we see some problems when we insert links to external sites into the body item of the content document.
The links look like this:
From the user perspective there is nothing special here. but when you open the document in the browser, some links are broken.
Notes sometimes seems to add extra (invisible) characters to the string when you save the document. It is an intermittent issue, but I am able to reproduce it. I have seen the same kind of error in therecently published article about Sametime in the IBM Lotus Sametime wiki. Go to the “Install the Meeting Server” section. Move the mouse over the C:\dnload link. There is an extra “close italic” tag in the link and I guess that this cannot be found in the document when opened in the client.
I did some investigation and looked at the cd-records of the body item. For all links that work without problems, there is a single cd-record
The broken links have multiple cd-records
I implemented a quick workaround by adding the following code to the custom control that displays the body item.
<xp:inputRichText id="entryBody" value="#{SingleEntry.body}" readonly="true" style="min-height:400px;"> <!-- solves issue with pasted links 28.10.2010, Ulrich Krause --> <xp:this.converter> <xp:customConverter getAsObject="#{javascript:value;}"> <xp:this.getAsString> <![CDATA[#{javascript: var html=value.toString(); html=html.replace(/href=\"<\/font>/g,"href=\""); return html; }]]> </xp:this.getAsString> </xp:customConverter> </xp:this.converter> <!-- end --> </xp:inputRichText>
This piece of code adds a custom converter that strips out the extra font tags from the link.