« Lessons Learned: Software Testing Automation | Main| Can a Notes database "really" be excluded from the Catalog? »

Laid Low by the Lowly Apostrophe - A Javascript Story

QuickImage Category

For the observant among you who noticed that in the past month or so the Lotus Guru blog site has been slightly, well, broken, I can now, FINALLY, explain why.  Ironically, given my comment in the last post on DBLookups about simple typos in your code causing major grief, something very similar turned out to be the culprit in this case.  And as usual, there is a lesson to be drawn from the episode, especially for you developers out there.

Since everything now be fixed, it's worth explaining what was broke before (its late - forgive my indifference to grammar).  Put simply, several "minor" bits of the site were not loading, including the little RSS icons, the search block, and the email and print icons next to each story title.  It was easy enough to trace this failure to a particular javascript page (blogsphere.js to be specific) not loading.  But hours of troubleshooting, trying to isolate why this was so led to countless dead-ends.  The problem didn't go away if I renamed the page and all references to it with Teamstudio Configurator  The problem didn't go away if I moved the database to a different server.  I updated the blogsphere template - no dice.  Switching CSS files, resaving all configuration docs, refreshing everything else - nada.  But if I pasted some of the rendered javascript directly into the JSHeader of the form, everything would start working fine, but that defeated the purpose of using Page design elements to build javascript dynamically with computed text.  Arghh!

In the end, it turned out I had been tantalizingly close to uncovering the problem when I pasted some javascript directly into the JSHeader.  Had I only pasted ALL of the rendered javascript from that page, I would have revealed a syntax error that prevented the javascript from saving.  Turns out that some of the aforementioned computed text was pulling values from a configuration document that contained an apostrophe, which is of course a special character in javascript.  This caused the affected line of javascript to break, and brought the whole @()#*$^! page down with it!

The apostrophe in question can be seen if you click on the little mail icon next to the title of this story.  This brings up a new mail message and puts the text "Saw this link up on Kevin Pettitt's Lotus Guru Blog and thought you might be interested..." into the message body.  Armed with the knowledge that this text was being pulled into some javascript I could add a backslash ("\") before the apostrophe, changing "Pettitt's" to Pettitt\'s", and fix the problem.

The high degree of configurability in the Blogsphere template offers tremendous flexibility, but there are still some areas where you have to be careful with odd characters that are treated as "special" by either URLs, HTML, XML, or javascript.  Earlier this year I fixed the issue of category names breaking if they contained either a space or a special character like & or ? that would otherwise confuse URLs.  I guess some sort of validation or dynamic string replacement might be in order in this case, but for now I'll make do with my simple "\" fix.  Me happy

Your Host

Kevin Pettitt View Kevin Pettitt's profile on LinkedIn

Tools I Use

Idea Jam

Subscribe to This Blog

 Full Posts  Comments

netvibes Add to Netvibes


Hosted by



This site is in no way affiliated, endorsed, sanctioned, supported, nor blessed by Lotus Software nor IBM Corporation, nor any of my past or future clients (although they are welcome to do so). The opinions, theories, facts, etc. presented here are my own and in no way represent any official pronouncement by me on behalf of any other entity.

© 2005-2019 Kevin Pettitt - all rights reserved as listed below.

Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution / NonCommercial / ShareAlike