Module: wine Branch: master Commit: 60e4f8a261ae9044aafa9c4eec2a3f2aec6481b5 URL: https://gitlab.winehq.org/wine/wine/-/commit/60e4f8a261ae9044aafa9c4eec2a3f2...
Author: David Kahurani k.kahurani@gmail.com Date: Wed Jun 21 12:07:11 2023 +0300
msi: Convert newlines to alternate representation when exporting.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54532 Signed-off-by: David Kahurani k.kahurani@gmail.com
---
dlls/msi/database.c | 18 +++++++++++++++++- dlls/msi/tests/db.c | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 2aaf495b728..a39321a18bb 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -892,7 +892,7 @@ end:
static UINT export_field( HANDLE handle, MSIRECORD *row, UINT field ) { - char *buffer; + char *buffer, *ptr; BOOL ret; DWORD sz = 0x100; UINT r; @@ -928,6 +928,22 @@ static UINT export_field( HANDLE handle, MSIRECORD *row, UINT field ) return r; }
+ ptr = buffer; + while( *ptr ) + { + if (*ptr == '\r' && *( ptr + 1 ) == '\n') + { + *ptr++ = '\x11'; + *ptr++ = '\x19'; + continue; + } + + if (*ptr == '\n') + *ptr = '\x19'; + + ptr++; + } + ret = WriteFile( handle, buffer, sz, &sz, NULL ); free( buffer ); return ret ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED; diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 29b8d45e25a..22fe92688ad 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -8584,12 +8584,18 @@ static void test_embedded_nulls(void) "s72\tL0\n" "Control\tDialog\n" "LicenseAgreementDlg\ttext\x11\x19text\0text"; + static const char export_expected[] = + "Dialog\tText\r\n" + "s72\tL0\r\n" + "Control\tDialog\r\n" + "LicenseAgreementDlg\ttext\x11\x19text\x19text"; /* newlines have alternate representation in idt files */ static const char control_table2[] = "Dialog\tText\n" "s72\tL0\n" "Control\tDialog\n" "LicenseAgreementDlg\ttext\x11\x19te\nxt\0text"; + char data[1024]; UINT r; DWORD sz; MSIHANDLE hdb, hrec; @@ -8613,6 +8619,12 @@ static void test_embedded_nulls(void) ok( r == ERROR_SUCCESS, "failed to get string %u\n", r ); ok( !memcmp( "text\r\ntext\ntext", buffer, sizeof("text\r\ntext\ntext") - 1 ), "wrong buffer contents "%s"\n", buffer );
+ r = MsiDatabaseExportA( hdb, "Control", CURR_DIR, "temp_file1"); + ok( r == ERROR_SUCCESS, "failed to export table %u\n", r ); + read_file_data( "temp_file1", data ); + ok( !memcmp( data, export_expected, sizeof(export_expected) - 1), "expected: "%s" got: "%s"\n", export_expected, data ); + DeleteFileA( "temp_file1" ); + MsiCloseHandle( hrec ); MsiCloseHandle( hdb ); DeleteFileA( msifile );