From c62b3639425751efd1c13efc594aeb2bf6192aaa Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 25 Oct 2008 14:40:48 +0000 Subject: [PATCH] bug #2107583 [GUI] Leading newline truncated, thanks to Isart Montane --- ChangeLog | 1 + libraries/common.lib.php | 17 +++++++++++++++++ tbl_change.php | 12 ++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d7a0b871..05306be97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA 3.0.2.0 (not yet released) - [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) - bug #2134126 [GUI] SQL error after sorting a subset diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 1af799a71..2c9e31c3a 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2610,4 +2610,21 @@ function PMA_replace_binary_contents($content) { $result = str_replace("\x1a", '\Z', $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; +} + ?> diff --git a/tbl_change.php b/tbl_change.php index 293e3fc22..90ad7ee40 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -429,6 +429,10 @@ foreach ($rows as $row_id => $vrow) { $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 @@ -657,7 +661,7 @@ foreach ($rows as $row_id => $vrow) { id="field__3" tabindex="" - > + > $vrow) { id="field__3" tabindex="" - > + > 32000) { @@ -812,7 +816,7 @@ foreach ($rows as $row_id => $vrow) { id="field__3" tabindex="" - > + > $vrow) { id="field__3" tabindex="" - > + >