Welcome!

If everyone is thinking the same, someone isn't thinking

Lori MacVittie

Subscribe to Lori MacVittie: eMailAlertsEmail Alerts
Get Lori MacVittie via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: Twitter on Ulitzer, Microsoft Developer, CIO/CTO Update, VITO Report

Blog Feed Post

Using Network-Side Scripting to Convert Microsoft Smart Quotes to HTML Entities

You can address the problem of converting smart quotes – and any other content - in your application if you control the code

You can address the problem of converting smart quotes – and any other content - in your application if you control the code. What if you’re using third-party software for which you do not have the code? Or what if it is your code but the “defect” is so low on the priority list that you won’t get to it until the year 2020?

Dealing with Microsoft smart quotes is a fact of life for developers. Almost every developer out there has a server-side script/function they use to strip them out of user-generated content and replace them with web-friendly HTML entities instead. But handling smart quotes in application code isn’t always possible or as high a priority as other tasks. If you were looking for a way to address smart quotes once and for all, across multiple applications with one, centralized simple method then a network-side scripting solution may be the answer.


COMMON SOLUTIONS


image

The solutions available today to address this annoyance are many but almost always involve either some client-side process or script, or the modification of server-side applications to recognize and replace the smart quotes with “dumb” HTML representations instead.

Solutions that require modification of the application work just fine, but must be implemented in every application for which such functionality is required. Another option is to simply enforce a “don’t use Microsoft tools to create web-based content.” That policy is likely to go over like a box of rocks as Microsoft tools are pervasive throughout most enterprise organizations.

blockquote Our department spends a lot of time pasting out of Word and into MT, and smart/curly quotes come out as question marks in some browsers. I was teaching staff to save as text first, open that in SimpleText or NotePad, and paste from there. They hated me for it. – forum post at SixApart discussing the problem of Microsoft “Smart Quotes” and how to get rid of them

 

 

In some situations there may be no viable solution other than a process similar to the one described in the forums at SixApart because you do not have access to the source code for the application.


THE NETWORK-SIDE SOLUTION


There is another solution to this problem, one that doesn’t require modifying the applications nor attempting to foist unenforceable policies on users nor requiring users to install or remember to use client-side plug-ins: network-side scripting. Using a network-side script on an application delivery controller (load balancer) offers a way to intercept the requests and replace any smart quotes with dumb quotes for all applications it delivers.

image

1. The client creates the content however they like, and enters it into the web application. It contains smart quotes.

2. The application delivery controller, which is already acting as a proxy for the application, sees the request and performs a search through the content to find all the smart quotes and then replaces them with dumb quotes.

3. The request is sent to the application with the modified content.

Alternatively, the application delivery controller can perform the search and replace of smart quotes with dumb quotes on the response instead.

  1. The client sends a request
  2. The application delivery controller notes the URI and determines the response will need processing
  3. When the response is received by the application delivery controller it executes logic to find all the smart quotes and replace them with their respective HTML entities.

In either case – replacement on request or response - the execution of the network-side script is transparent; neither the user nor the application is necessarily aware of the script and change to the content. The application delivery controller can further be configured such that only the URIs (requests) specifically known to contain content that might include smart quotes will be examined, thus alleviating any potential concerns about the impact of search and replace functionality on performance.

Here’s an example of modifying content on the response. Notice that when the request is received you need to set a flag only if the URI is one for which you know will need to be “scrubbed” of quotes:

More Stories By Lori MacVittie

Lori MacVittie is responsible for education and evangelism of application services available across F5’s entire product suite. Her role includes authorship of technical materials and participation in a number of community-based forums and industry standards organizations, among other efforts. MacVittie has extensive programming experience as an application architect, as well as network and systems development and administration expertise. Prior to joining F5, MacVittie was an award-winning Senior Technology Editor at Network Computing Magazine, where she conducted product research and evaluation focused on integration with application and network architectures, and authored articles on a variety of topics aimed at IT professionals. Her most recent area of focus included SOA-related products and architectures. She holds a B.S. in Information and Computing Science from the University of Wisconsin at Green Bay, and an M.S. in Computer Science from Nova Southeastern University.