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>
This commit is contained in:
David Kahurani 2023-06-21 12:07:11 +03:00 committed by Alexandre Julliard
parent e1ddc58a25
commit 60e4f8a261
2 changed files with 29 additions and 1 deletions

View file

@ -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;

View file

@ -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 );