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) { ...@@ -117,7 +117,7 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') { if ($type == 'comment') {
$query_arr['comment'] = $node->cid; $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; if (empty($query)) $query = NULL;
$links['print'] = array('href' => PRINT_PATH .'/'. $node->nid, $links['print'] = array('href' => PRINT_PATH .'/'. $node->nid,
...@@ -359,7 +359,7 @@ function print_insert_link($path = NULL) { ...@@ -359,7 +359,7 @@ function print_insert_link($path = NULL) {
if (user_access('access print')) { if (user_access('access print')) {
if ($path === NULL) { if ($path === NULL) {
$path = PRINT_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']); $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)) { if (empty($query)) {
$query = NULL; $query = NULL;
} }
...@@ -373,7 +373,7 @@ function print_insert_link($path = NULL) { ...@@ -373,7 +373,7 @@ function print_insert_link($path = NULL) {
* Determine if the current page is enabled according to the visibility settings * Determine if the current page is enabled according to the visibility settings
* *
* @param $visibility * @param $visibility
* current visibility settings: * current visibility settings:
* 0 for show on every page except the listed pages * 0 for show on every page except the listed pages
* 1 for show on only the listed pages * 1 for show on only the listed pages
* @param $pages * @param $pages
...@@ -425,7 +425,7 @@ function print_link_allowed($args) { ...@@ -425,7 +425,7 @@ function print_link_allowed($args) {
$print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT); $print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT);
$print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT); $print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT);
if ($node->printing || if ($node->printing ||
!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) { !_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) {
// Page not in visibility list or we are working! // Page not in visibility list or we are working!
return FALSE; return FALSE;
...@@ -436,7 +436,7 @@ function print_link_allowed($args) { ...@@ -436,7 +436,7 @@ function print_link_allowed($args) {
} }
else { else {
// Node link // Node link
if (isset($node_type) && if (isset($node_type) &&
!variable_get('print_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT)) { !variable_get('print_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT)) {
// Link for this node type is disabled // Link for this node type is disabled
return FALSE; return FALSE;
...@@ -465,3 +465,26 @@ function print_link_allowed($args) { ...@@ -465,3 +465,26 @@ function print_link_allowed($args) {
return _print_page_match($print_html_sys_link_visibility, $print_html_sys_link_pages); 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) { ...@@ -102,6 +102,7 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy'])))); $keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
$pdf->SetKeywords($keys); $pdf->SetKeywords($keys);
$pdf->setPDFVersion('1.6'); $pdf->setPDFVersion('1.6');
$pdf->setUserRights();
// set header data // set header data
$pdf->SetHeaderData('', 0, $print['title'], strip_tags($print['site_name'])); $pdf->SetHeaderData('', 0, $print['title'], strip_tags($print['site_name']));
...@@ -121,6 +122,9 @@ function _print_pdf_tcpdf($print, $html, $filename) { ...@@ -121,6 +122,9 @@ function _print_pdf_tcpdf($print, $html, $filename) {
// set image scale factor // set image scale factor
$pdf->setImageScale(4); $pdf->setImageScale(4);
// set image compression quality
$pdf->setJPEGQuality(100);
//initialize document //initialize document
$pdf->AliasNbPages(); $pdf->AliasNbPages();
......
...@@ -89,7 +89,7 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) { ...@@ -89,7 +89,7 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') { if ($type == 'comment') {
$query_arr['comment'] = $node->cid; $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, $links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $node->nid,
'title' => $format['text'], 'title' => $format['text'],
...@@ -199,7 +199,7 @@ function print_mail_insert_link($path = NULL) { ...@@ -199,7 +199,7 @@ function print_mail_insert_link($path = NULL) {
if (user_access('access print')) { if (user_access('access print')) {
if ($path === NULL) { if ($path === NULL) {
$path = PRINTMAIL_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']); $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)) { if (empty($query)) {
$query = NULL; $query = NULL;
} }
......
...@@ -108,7 +108,7 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) { ...@@ -108,7 +108,7 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
if ($type == 'comment') { if ($type == 'comment') {
$query_arr['comment'] = $node->cid; $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, $links['print_pdf'] = array('href' => PRINTPDF_PATH .'/'. $node->nid,
'title' => $format['text'], 'title' => $format['text'],
...@@ -219,7 +219,7 @@ function print_pdf_insert_link($path = NULL) { ...@@ -219,7 +219,7 @@ function print_pdf_insert_link($path = NULL) {
if (user_access('access print')) { if (user_access('access print')) {
if ($path === NULL) { if ($path === NULL) {
$path = PRINTPDF_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']); $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)) { if (empty($query)) {
$query = NULL; $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