From 1418e3b6addb197839e5c0249a3e470962b87240 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Thu, 12 Dec 2024 14:01:13 +0000 Subject: [PATCH] Fix: #5075 - trailing space after empty NOTE tag --- app/Services/GedcomImportService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Services/GedcomImportService.php b/app/Services/GedcomImportService.php index ab31c6da8f3..650f44be6b0 100644 --- a/app/Services/GedcomImportService.php +++ b/app/Services/GedcomImportService.php @@ -196,13 +196,13 @@ private function reformatRecord(string $rec, Tree $tree): string while (str_contains($data, ' ')) { $data = strtr($data, [' ' => ' ']); } - $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data); + $newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data); break; case 'NOTE': case 'TEXT': case 'DATA': case 'CONT': - $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data); + $newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data); break; case 'FILE': // Strip off the user-defined path prefix @@ -213,7 +213,7 @@ private function reformatRecord(string $rec, Tree $tree): string // convert backslashes in filenames to forward slashes $data = preg_replace("/\\\\/", '/', $data); - $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level === '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag !== 'NOTE' ? '' : ' ' . $data); + $newrec .= ($newrec !== '' ? "\n" : '') . $level . ' ' . ($level === '0' && $xref !== '' ? $xref . ' ' : '') . $tag . ($data === '' ? '' : ' ' . $data); break; case 'CONC': // Merge CONC lines, to simplify access later on.