When clean URLs are enabled on filtering, e.g. /biblio/author/Smith or /biblio/year/2009, download links for papers become incorrect, pointing to /biblio/author/Smith/files/file.pdf instead of /files/file.pdf. The following patch fixes the problem:

Index: biblio.module
===================================================================
--- biblio.module       (revision 226)
+++ biblio.module       (working copy)
@@ -2051,7 +2051,7 @@
       $output .= '   '. t('Download') .': ';
       $output .= '<span class="biblio_export_links">';
       foreach ($node->files as $file) {
-        $output .= '&nbsp;<a href="' . $file->filepath . '">' . $file->filename . '</a>&nbsp;';
+        $output .= '&nbsp;<a href="' . file_create_url($file->filepath) . '">' . $file->filename . '</a>&nbsp;';
       }
       $output .= '</span>';
     }

Please review.

CommentFileSizeAuthor
fix-biblio-download.patch596 bytesAlexander Ufimtsev

Comments

rjerome’s picture

Thanks for pointing that out, I'm surprised no one ran into this before.

I did something a little different than you suggested, I used the l() function instead like this...

$output .= '&nbsp;'. l($file->filename, $file->filepath). '&nbsp;';

Ron.

Alexander Ufimtsev’s picture

Yes, l() seems to be more elegant, though both of l() and file_create_url() end up calling url() at the end of the day anyway. I'm also surprised that out of almost 300 installations we were the first to spot this bug.

Thank you, Ron!

Alexander

rjerome’s picture

FYI, I'm going to roll a new 5.x release later this week which will contain this fix as well as a few enhancements (some new styles: AMA, Chicago, MLA and Vancouver)

Ron.

rjerome’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Alexander Ufimtsev’s picture

Hi Ron,

Any chance of a release any time soon?

A

rjerome’s picture

Status: Closed (fixed) » Active

Oops, this one completely slipped my mind (and since it was automatically closed) it slipped off the radar screen, sorry about that.

rjerome’s picture

The new release is out now.

Ron.

Alexander Ufimtsev’s picture

Status: Active » Fixed

cheers! works perfectly!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.