Commit 8c99bfd6 authored by jcnventura's avatar jcnventura

Fix obscure pattern matching bug for sites that still use index.php in the URL

parent ce25e796
......@@ -216,6 +216,22 @@ function print_help($path, $arg) {
}
}
/**
* Implementation of hook_nodeapi().
*/
function print_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
if (TRUE && !$node->printing) {
$link = print_insert_link();
$node->content['print_link'] = array(
'#value' => "<div style='float:right;clear:left;margin: 0 0 1em 2em;'>$link</div>",
'#weight' => -1,
);
}
}
}
/**
* Implementation of hook_form_alter().
*/
......
......@@ -313,7 +313,7 @@ function _print_rewrite_urls($matches) {
for ($i=1; $i < count($attribs); $i++) {
// If the attribute is href or src, we may need to rewrite the URL in the value
if (preg_match("/^(href|src)\s*?=/i", $attribs[$i]) > 0) {
if (preg_match("/^(?:href|src)\s*?=/i", $attribs[$i]) > 0) {
// We may need to rewrite the URL, so let's isolate it
preg_match("/.*?=(.*)/is", $attribs[$i], $urls);
$url = trim($urls[1], " \t\n\r\0\x0B\"\'");
......@@ -344,7 +344,7 @@ function _print_rewrite_urls($matches) {
// If it starts with '/' just append it to the server name
$newurl = $base_root .'/'. trim(urldecode($url), "/");
}
elseif ((!$clean_url) && (preg_match("/^[index.php]?\?q=.*/i", $url))) {
elseif ((!$clean_url) && (preg_match("/^(?:index.php)?\?q=.*/i", $url))) {
// If Clean URLs is disabled, and it starts with q=?, just prepend with the base URL
$newurl = $base_url .'/'. trim(urldecode($url), "/");
}
......
......@@ -149,6 +149,22 @@ function print_mail_help($path, $arg) {
}
}
/**
* Implementation of hook_nodeapi().
*/
function print_mail_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
if (TRUE && !$node->printing) {
$link = print_mail_insert_link();
$node->content['print_mail_link'] = array(
'#value' => "<div style='float:right;clear:left;'>$link</div>",
'#weight' => -2,
);
}
}
}
/**
* Implementation of hook_form_alter().
*/
......
......@@ -168,6 +168,22 @@ function print_pdf_help($path, $arg) {
}
}
/**
* Implementation of hook_nodeapi().
*/
function print_pdf_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
if (TRUE && !$node->printing) {
$link = print_pdf_insert_link();
$node->content['print_pdf_link'] = array(
'#value' => "<div style='float:right;clear:left;'>$link</div>",
'#weight' => -3,
);
}
}
}
/**
* Implementation of hook_form_alter().
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment