Commit 2d95fba8 authored by jcnventura's avatar jcnventura

Issue #1196588: use ctype_digit to check if a given string is a number.

parent a5e87960
......@@ -245,7 +245,7 @@ function print_block_view($delta = '') {
switch ($delta) {
case 'print-links':
$nid = preg_replace('!^node/!', '', $_GET['q']);
if (is_numeric($nid)) {
if (ctype_digit($nid)) {
$node = node_load($nid);
}
else {
......@@ -551,7 +551,7 @@ function _print_set_node_fields(&$node) {
function _print_get_title($path) {
$path = drupal_get_normal_path($path);
$nid = preg_replace('!^node/!', '', $path);
if (is_numeric($nid)) {
if (ctype_digit($nid)) {
$res = db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => $nid))
->fetchField();
}
......@@ -800,7 +800,7 @@ function print_link_allowed($args) {
}
if (!empty($args['path'])) {
$nid = preg_replace('!^node/!', '', drupal_get_normal_path($args['path']));
if (is_numeric($nid)) {
if (ctype_digit($nid)) {
$args['node'] = node_load($nid);
}
}
......
......@@ -74,7 +74,7 @@ function print_controller($path, $cid = NULL, $format = PRINT_HTML_FORMAT, $teas
$path = '';
}
}
if (!is_numeric($path)) {
if (!ctype_digit($path)) {
// Indirect call with print/alias
// If there is a path alias with these arguments, generate a printer-friendly version for it
$path = drupal_get_normal_path($path);
......@@ -84,7 +84,7 @@ function print_controller($path, $cid = NULL, $format = PRINT_HTML_FORMAT, $teas
}
}
$parts = explode('/', $path);
if (is_numeric($parts[0]) && (count($parts) == 1)) {
if (ctype_digit($parts[0]) && (count($parts) == 1)) {
$print = _print_generate_node($path, $cid, $format, $teaser, $message);
}
else {
......@@ -345,7 +345,7 @@ function _print_rewrite_urls($matches) {
$path = explode('/', $_GET['q']);
unset($path[0]);
$path = implode('/', $path);
if (is_numeric($path)) {
if (ctype_digit($path)) {
$path = "node/$path";
}
// Printer-friendly URLs is on, so we need to make it absolute
......@@ -585,7 +585,7 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS
// Handle node tabs
$parts = explode('/', $path);
if (is_numeric($parts[0]) && (count($parts) > 1)) {
if (ctype_digit($parts[0]) && (count($parts) > 1)) {
$path = 'node/' . $path;
}
......
......@@ -485,7 +485,7 @@ function print_mail_link_allowed($args) {
}
if (!empty($args['path'])) {
$nid = preg_replace('!^node/!', '', drupal_get_normal_path($args['path']));
if (is_numeric($nid)) {
if (ctype_digit($nid)) {
$args['node'] = node_load($nid);
}
}
......
......@@ -544,7 +544,7 @@ function print_pdf_link_allowed($args) {
}
if (!empty($args['path'])) {
$nid = preg_replace('!^node/!', '', drupal_get_normal_path($args['path']));
if (is_numeric($nid)) {
if (ctype_digit($nid)) {
$args['node'] = node_load($nid);
}
}
......
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