if (isset($vrow)) { if (is_null($vrow[$field['Field']])) { $real_null_value = TRUE; $vrow[$field['Field']] = ''; $special_chars = ''; $data = $vrow[$field['Field']]; } elseif ($field['True_Type'] == 'bit') { $special_chars = PMA_printable_bit_value($vrow[$field['Field']], $extracted_fieldspec['spec_in_brackets']); } else { // loic1: special binary "characters" if ($field['is_binary'] || $field['is_blob'] && !$cfg['ProtectBinary']) { if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) { $vrow[$field['Field']] = bin2hex($vrow[$field['Field']]); $field['display_binary_as_hex'] = true; } else { $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]); } } // end if $special_chars = htmlspecialchars($vrow[$field['Field']]); //We need to duplicate the first \n or otherwise we will lose the first newline entered in a VARCHAR or TEXT column $special_chars_encoded = PMA_duplicateFirstNewline($special_chars); $data = $vrow[$field['Field']]; } // end if... else... // loic1: if a timestamp field value is not included in an update // statement MySQL auto-update it to the current timestamp // lem9: however, things have changed since MySQL 4.1, so // it's better to set a fields_prev in this situation $backup_field = '<input type="hidden" name="fields_prev' . $field_name_appendix . '" value="' . htmlspecialchars($vrow[$field['Field']]) . '" />'; } else {
/** * Verifies what to do with non-printable contents (binary or BLOB) * in Browse mode. * * @uses is_null() * @uses isset() * @uses strlen() * @uses PMA_formatByteDown() * @uses strpos() * @uses str_replace() * @param string $category BLOB|BINARY|GEOMETRY * @param string $content the binary content * @param string $transform_function * @param string $transform_options * @param string $default_function * @param object $meta the meta-information about this field * @return mixed string or float */ function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array()) { $result = '[' . $category; if (is_null($content)) { $result .= ' - NULL'; $size = 0; } elseif (isset($content)) { $size = strlen($content); $display_size = PMA_formatByteDown($size, 3, 1); $result .= ' - ' . $display_size[0] . $display_size[1]; } $result .= ']'; if (strpos($transform_function, 'octetstream')) { $result = $content; } if ($size > 0) { if ($default_function != $transform_function) { $result = $transform_function($result, $transform_options, $meta); } else { $result = $default_function($result, array(), $meta); if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) { // in this case, restart from the original $content $result = htmlspecialchars(PMA_replace_binary_contents($content)); } /* Create link to download */ if (count($url_params) > 0) { $result = '<a href="tbl_get_field.php' . PMA_generate_common_url($url_params) . '">' . $result . '</a>'; } } } return $result; }
/** * Verifies what to do with non-printable contents (binary or BLOB) * in Browse mode. * * @uses is_null() * @uses isset() * @uses strlen() * @uses PMA_formatByteDown() * @uses strpos() * @uses str_replace() * @param string $category BLOB|BINARY * @param string $content the binary content * @param string $transform_function * @param string $transform_options * @param string $default_function * @param object $meta the meta-information about this field * @return mixed string or float */ function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta) { $result = '[' . $category; if (is_null($content)) { $result .= ' - NULL'; $size = 0; } elseif (isset($content)) { $size = strlen($content); $display_size = PMA_formatByteDown($size, 3, 1); $result .= ' - ' . $display_size[0] . $display_size[1]; } $result .= ']'; if (strpos($transform_function, 'octetstream')) { $result = $content; } if ($size > 0) { if ($default_function != $transform_function) { $result = $transform_function($result, $transform_options, $meta); } else { $result = $default_function($result, array(), $meta); if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) { // in this case, restart from the original $content $result = htmlspecialchars(PMA_replace_binary_contents($content)); } } } return $result; }
/** * replace binary contents test * @dataProvider replaceBinaryContentsDataProvider */ public function testReplaceBinaryContents($a, $e) { $this->assertEquals($e, PMA_replace_binary_contents($a)); }