Commit 973f5b72 authored by jcnventura's avatar jcnventura

Fix #285496: prevent re-encoding of the encoded query

Fix some minor coder warnings
Add some TCPDF calls for better quality output
parent a8222e12
......@@ -117,7 +117,7 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = drupal_query_string_encode($query_arr, array('q'));
$query = print_query_string_encode($query_arr, array('q'));
if (empty($query)) $query = NULL;
$links['print'] = array('href' => PRINT_PATH .'/'. $node->nid,
......@@ -359,7 +359,7 @@ function print_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINT_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$query = drupal_query_string_encode($_GET, array('q'));
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
}
......@@ -465,3 +465,26 @@ function print_link_allowed($args) {
return _print_page_match($print_html_sys_link_visibility, $print_html_sys_link_pages);
}
}
/**
* Parse an array into a valid urlencoded query string.
* Modified from drupal_query_string_encode to prevent re-encoding of
* encoded original.
*
* @param $query
* The array to be processed e.g. $_GET
* @param $exclude
* The array filled with keys to be excluded.
* @return
* urlencoded string which can be appended to/as the URL query string
*/
function print_query_string_encode($query, $exclude = array()) {
$params = array();
foreach ($query as $key => $value) {
if (in_array($key, $exclude)) {
continue;
}
$params[] = $key .'='. rawurlencode($value);
}
return implode('&', $params);
}
......@@ -102,6 +102,7 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
$pdf->SetKeywords($keys);
$pdf->setPDFVersion('1.6');
$pdf->setUserRights();
// set header data
$pdf->SetHeaderData('', 0, $print['title'], strip_tags($print['site_name']));
......@@ -121,6 +122,9 @@ function _print_pdf_tcpdf($print, $html, $filename) {
// set image scale factor
$pdf->setImageScale(4);
// set image compression quality
$pdf->setJPEGQuality(100);
//initialize document
$pdf->AliasNbPages();
......
......@@ -89,7 +89,7 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = drupal_query_string_encode($query_arr, array('q'));
$query = print_query_string_encode($query_arr, array('q'));
$links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $node->nid,
'title' => $format['text'],
......@@ -199,7 +199,7 @@ function print_mail_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINTMAIL_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$query = drupal_query_string_encode($_GET, array('q'));
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
}
......
......@@ -108,7 +108,7 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = drupal_query_string_encode($query_arr, array('q'));
$query = print_query_string_encode($query_arr, array('q'));
$links['print_pdf'] = array('href' => PRINTPDF_PATH .'/'. $node->nid,
'title' => $format['text'],
......@@ -219,7 +219,7 @@ function print_pdf_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINTPDF_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$query = drupal_query_string_encode($_GET, array('q'));
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
}
......
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