Printer-friendly version mangles some types of link

Trejkaz - November 4, 2009 - 22:47
Project:Printer, e-mail and PDF versions
Version:6.x-1.10
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

The markdown module performs some mangling for mail addresses to make it (slightly) harder for a spammer to read the address.

If you enter this:

Here is an email address: <support@example.com>

You get this:

<span class='print-link'></span><p>Here is an email address: <a href="&#109;&#97;&#x69;&#x6c;&#x74;&#111;&#58;&#115;&#x75;&#x70;p&#111;&#114;&#x74;&#x40;e&#120;&#97;&#x6d;&#x70;&#x6c;&#101;&#46;&#x63;&#x6f;&#x6d;">&#115;&#x75;&#x70;p&#111;&#114;&#x74;&#x40;e&#120;&#97;&#x6d;&#x70;&#x6c;&#101;&#46;&#x63;&#x6f;&#x6d;</a></p>

And this works fine in a web browser.

However, view the printer-friendly version of the page, and the source becomes this:

<div class="print-content"><p>Here is an email address: <a href="https://download.nuix.com/%2526%2523109%3B%2526%252397%3B%2526%2523x69%3B%2526%2523x6c%3B%2526%2523x74%3B%2526%2523111%3B%2526%252358%3B%2526%2523115%3B%2526%2523x75%3B%2526%2523x70%3Bp%2526%2523111%3B%2526%2523114%3B%2526%2523x74%3B%2526%2523x40%3Be%2526%2523120%3B%2526%252397%3B%2526%2523x6d%3B%2526%2523x70%3B%2526%2523x6c%3B%2526%2523101%3B%2526%252346%3B%2526%2523x63%3B%2526%2523x6f%3B%2526%2523x6d%3B">&#115;&#x75;&#x70;p&#111;&#114;&#x74;&#x40;e&#120;&#97;&#x6d;&#x70;&#x6c;&#101;&#46;&#x63;&#x6f;&#x6d;</a> <span class="print-footnote">[1]</span></p>

...

[1] https://download.nuix.com/%2526%2523109%3B%2526%252397%3B%2526%2523x69%3...

Basically the print module is performing an additional level of escaping, which is causing the URL to break as it is no longer a mailto: URL. I would expect this to break some other types of URL as well (anything containing character escapes which are already escaped), which is why I have titled this bug more generally.

#1

brankoc - November 19, 2009 - 20:55

I can confirm this. A link with plusses in it gets translated to a link with spaces in it. For instance, "see+spot+run.pdf" becomes "see spot run.pdf".

The problem would seem to be the usage of urldecode() in print.pages.inc, for instance in the line:

$newurl = urldecode($url);.

 
 

Drupal is a registered trademark of Dries Buytaert.