bug #2107583 [GUI] Leading newline truncated, thanks to Isart Montane

This commit is contained in:
Marc Delisle
2008-10-25 14:40:48 +00:00
parent 8c697864eb
commit c62b363942
3 changed files with 26 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
3.0.2.0 (not yet released) 3.0.2.0 (not yet released)
- [lang] Italian update, thanks to Luca and fantu - [lang] Italian update, thanks to Luca and fantu
- bug #2107583 [GUI] Leading newline truncated, thanks to Isart Montane
3.0.1.0 (2008-10-22) 3.0.1.0 (2008-10-22)
- bug #2134126 [GUI] SQL error after sorting a subset - bug #2134126 [GUI] SQL error after sorting a subset

View File

@@ -2610,4 +2610,21 @@ function PMA_replace_binary_contents($content) {
$result = str_replace("\x1a", '\Z', $result); $result = str_replace("\x1a", '\Z', $result);
return $result; return $result;
} }
/**
*
* If the first character given is \n (CR) we will add an extra \n
*
* @uses strpos()
* @return string with the chars replaced
*/
function PMA_duplicateFirstNewline($string){
$first_occurence = strpos($string, "\n");
if($first_occurence == 1){
$string = "\n".$string;
}
return $string;
}
?> ?>

View File

@@ -429,6 +429,10 @@ foreach ($rows as $row_id => $vrow) {
$vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]); $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]);
} // end if } // end if
$special_chars = htmlspecialchars($vrow[$field['Field']]); $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']]; $data = $vrow[$field['Field']];
} // end if... else... } // end if... else...
// loic1: if a timestamp field value is not included in an update // loic1: if a timestamp field value is not included in an update
@@ -657,7 +661,7 @@ foreach ($rows as $row_id => $vrow) {
id="field_<?php echo ($idindex); ?>_3" id="field_<?php echo ($idindex); ?>_3"
<?php echo $unnullify_trigger; ?> <?php echo $unnullify_trigger; ?>
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
><?php echo $special_chars; ?></textarea> ><?php echo $special_chars_encoded; ?></textarea>
<?php <?php
} elseif (strstr($field['pma_type'], 'text')) { } elseif (strstr($field['pma_type'], 'text')) {
echo $backup_field . "\n"; echo $backup_field . "\n";
@@ -669,7 +673,7 @@ foreach ($rows as $row_id => $vrow) {
id="field_<?php echo ($idindex); ?>_3" id="field_<?php echo ($idindex); ?>_3"
<?php echo $unnullify_trigger; ?> <?php echo $unnullify_trigger; ?>
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
><?php echo $special_chars; ?></textarea> ><?php echo $special_chars_encoded; ?></textarea>
<?php <?php
echo "\n"; echo "\n";
if (strlen($special_chars) > 32000) { if (strlen($special_chars) > 32000) {
@@ -812,7 +816,7 @@ foreach ($rows as $row_id => $vrow) {
id="field_<?php echo ($idindex); ?>_3" id="field_<?php echo ($idindex); ?>_3"
<?php echo $unnullify_trigger; ?> <?php echo $unnullify_trigger; ?>
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
><?php echo $special_chars; ?></textarea> ><?php echo $special_chars_encoded; ?></textarea>
<?php <?php
} else { } else {
@@ -889,7 +893,7 @@ foreach ($rows as $row_id => $vrow) {
id="field_<?php echo ($idindex); ?>_3" id="field_<?php echo ($idindex); ?>_3"
<?php echo $unnullify_trigger; ?> <?php echo $unnullify_trigger; ?>
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
><?php echo $special_chars; ?></textarea> ><?php echo $special_chars_encoded; ?></textarea>
<?php <?php
} else { } else {
?> ?>