Oh My Word!

Microsoft Word Icon

About a month ago, we ran into a problem with hyperlinks in a Microsoft Word document. Wait! What? H-y-p-e-r-l-i-n-k-s? Yup. The most basic operation known in the history of the internet; the fundamental building block for information sharing in today’s technological landscape.

So, we decided to build a function in a web application which outputs a Microsoft Word document complete with links. Here’s the kicker. When we finally succeeded in generating the Word document, we opened it and tried the links. This produced some weird results and basically failed when linking back to our web application.

OK, here’s the deal. Have you ever noticed that whenever you click on a link in a Microsoft Word document, a status bar appears at the bottom of the document window? Have you ever wondered what in the world it’s doing? I have, but never pursued finding out.

As it turns out, Microsoft Word first sends the request to one of Microsoft’s servers. Then, Microsoft’s server sends the request back to the intended location. The problem is that it sends the request back, which is now originating from Microsoft’s server, void of any session data. So, if the end-user is logged in with established session data, good luck in successfully routing the user to the target… at this point, the request is coming from another user-agent.

So, here’s what we had to do in PHP to remedy this rather perplexing situation:

if(stristr($_SERVER['HTTP_USER_AGENT'], 'Word'))
{
die();
}

One can only speculate what Microsoft is doing with all of these requests. For some reason, I’m leaning towards the word “harvest”. I surely hope this helps and saves time for anyone who runs into this issue! Microsoft #fail.

Like this:

Tags: ,

%d bloggers like this: