From 4f7f7120f5dbc76f9b450d8cf184dc99ea826fd9 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 f7260041b..f122ac0b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,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 5c31d9782..fe67a9f94 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2644,4 +2644,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 a3cf90b54..c07e3ad9d 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) { @@ -867,7 +871,7 @@ foreach ($rows as $row_id => $vrow) { id="field__3" tabindex="" - > + > $vrow) { id="field__3" tabindex="" - > + >