summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--print.pages.inc14
-rw-r--r--tests/print_basic.test19
2 files changed, 25 insertions, 8 deletions
diff --git a/print.pages.inc b/print.pages.inc
index 4ddfd02..8fc9d83 100644
--- a/print.pages.inc
+++ b/print.pages.inc
@@ -375,9 +375,9 @@ function _print_rewrite_urls($matches) {
if (preg_match('!^(?:href|src)\s*?=(.*)!i', $attribs[$i], $urls) > 0) {
$url = trim($urls[1], " \t\n\r\0\x0B\"'");
- if (strpos($url, '://') || preg_match('!^mailto:.*?@.*?\..*?$!iu', $url)) {
+ if (strpos(html_entity_decode($url), '://') || preg_match('!^mailto:.*?@.*?\..*?$!iu', html_entity_decode($url))) {
// URL is absolute, do nothing
- $newurl = urldecode($url);
+ $newurl = $url;
}
else {
if ($url[0] == '#') {
@@ -390,7 +390,7 @@ function _print_rewrite_urls($matches) {
$path = "node/$path";
}
// Printer-friendly URLs is on, so we need to make it absolute
- $newurl = url($path, NULL, substr(urldecode($url), 1), TRUE);
+ $newurl = url($path, NULL, substr($url, 1), TRUE);
}
// Because base href is the original page, change the link to
// still be usable inside the print page
@@ -400,14 +400,14 @@ function _print_rewrite_urls($matches) {
// URL is relative, convert it into absolute URL
if ($url[0] == '/') {
// If it starts with '/' just append it to the server name
- $newurl = $base_root .'/'. trim(urldecode($url), '/');
+ $newurl = $base_root .'/'. trim($url, '/');
}
elseif (preg_match('!^(?:index.php)?\?q=!i', $url)) {
// If it starts with ?q=, just prepend with the base URL
- $newurl = $base_url .'/'. trim(urldecode($url), '/');
+ $newurl = $base_url .'/'. trim($url, '/');
}
else {
- $newurl = url(trim(urldecode($url), '/'), NULL, NULL, TRUE);
+ $newurl = url(trim($url, '/'), NULL, NULL, TRUE);
}
$matches[1] = str_replace($url, $newurl, $matches[1]);
}
@@ -419,7 +419,7 @@ function _print_rewrite_urls($matches) {
if (count($matches) == 4) {
$ret .= $matches[2] . $matches[3];
if ((!empty($_print_urls)) && (isset($newurl))) {
- $ret .= ' <span class="print-footnote">['. _print_friendly_urls(trim(stripslashes($newurl))) .']</span>';
+ $ret .= ' <span class="print-footnote">['. _print_friendly_urls(trim($newurl)) .']</span>';
}
}
diff --git a/tests/print_basic.test b/tests/print_basic.test
index be85d75..b7b5547 100644
--- a/tests/print_basic.test
+++ b/tests/print_basic.test
@@ -69,7 +69,7 @@ class PrintBasicTest extends DrupalTestCase {
$url[3] = 'relative/to/base';
$url[4] = 'index.php?q=sample/path';
$rel_url[0] = $url[0];
- $rel_url[1] = $_GET['q'] . $url[1];
+ $rel_url[1] = base_path() . $_GET['q'] . $url[1];
$rel_url[2] = $base_root . $url[2];
$rel_url[3] = $base_url .'/'. $url[3];
$rel_url[4] = $base_url .'/'. $url[4];
@@ -79,6 +79,23 @@ class PrintBasicTest extends DrupalTestCase {
$abs_url[3] = $base_url .'/'. $url[3];
$abs_url[4] = $base_url .'/'. $url[4];
+ $url[5] = '#here with spaces';
+ $url[6] = '/relative/to/host with spaces';
+ $url[7] = 'relative/to/base with spaces';
+ $url[8] = 'index.php?q=sample/path with spaces';
+ $rel_url[5] = base_path() . $_GET['q'] . $url[5];
+ $rel_url[6] = $base_root . $url[6];
+ $rel_url[7] = $base_url .'/'. $url[7];
+ $rel_url[8] = $base_url .'/'. $url[8];
+ $abs_url[5] = $base_url .'/'. $this->getq . $url[5];
+ $abs_url[6] = $base_root . $url[6];
+ $abs_url[7] = $base_url .'/'. $url[7];
+ $abs_url[8] = $base_url .'/'. $url[8];
+
+ $url[9] = '&#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;';
+ $rel_url[9] = $url[9];
+ $abs_url[9] = $url[9];
+
$size = count($url);
for ($i = 0; $i < $size; $i++) {
preg_match($pattern, $part1 . $url[$i] . $part2, $matches);