[PATCH 2/2] setupapi: Strip trailing spaces from field values.

Dmitry Timoshkov dmitry at baikal.ru
Thu Sep 10 08:32:08 CDT 2020


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/setupapi/parser.c       | 12 ++++++++++++
 dlls/setupapi/tests/parser.c |  3 ---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 560c2401b8..f15009be88 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -524,6 +524,17 @@ static int add_section_from_token( struct parser *parser )
 }
 
 
+static void strip_trailing_spaces( WCHAR *text )
+{
+    int len = wcslen( text );
+
+    while (len > 1 && text[len - 1] == ' ')
+    {
+        text[len - 1] = 0;
+        len--;
+    }
+}
+
 /* add a field containing the current token to the current line */
 static struct field *add_field_from_token( struct parser *parser, BOOL is_key )
 {
@@ -542,6 +553,7 @@ static struct field *add_field_from_token( struct parser *parser, BOOL is_key )
     else assert(!is_key);
 
     text = push_string( parser->file, parser->token );
+    strip_trailing_spaces( text );
     if ((field = add_field( parser->file, text )))
     {
         if (!is_key) parser->line->nb_fields++;
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 4f7736473c..4428413c36 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -821,21 +821,18 @@ static void test_SetupGetStringField(void)
     ok(ret, "SetupFindFirstLine error %u\n", GetLastError());
     ret = SetupGetStringFieldA(&context, 1, buf, sizeof(buf), NULL);
     ok(ret, "SetupGetStringField error %u\n", GetLastError());
-todo_wine
     ok(!strcmp(buf, "Company Name.Admin\\InstallerData\\Product Name\\1.2.3.45678_{11111111-1234-5678-1234-567812345678}\\Sources\\Setup.msi"), "got %s\n", buf);
 
     ret = SetupFindFirstLineA(hinf, "MSIinstaller", "Name2", &context);
     ok(ret, "SetupFindFirstLine error %u\n", GetLastError());
     ret = SetupGetStringFieldA(&context, 1, buf, sizeof(buf), NULL);
     ok(ret, "SetupGetStringField error %u\n", GetLastError());
-todo_wine
     ok(!strcmp(buf, "Company Name.Admin\\InstallerData\\Product Name\\1.2.3.45678_{22222222-1234-5678-1234 -567812345678}\\Sources\\Setup.msi"), "got %s\n", buf);
 
     ret = SetupFindFirstLineA(hinf, "MSIinstaller", "Name3", &context);
     ok(ret, "SetupFindFirstLine error %u\n", GetLastError());
     ret = SetupGetStringFieldA(&context, 1, buf, sizeof(buf), NULL);
     ok(ret, "SetupGetStringField error %u\n", GetLastError());
-todo_wine
     ok(!strcmp(buf, "Company Name.Admin\\InstallerData\\Product Name\\1.2.3.45678_{33333333-1234-5678-1234-567812345678}\\Sources\\Setup.msi"), "got %s\n", buf);
 
     SetupCloseInfFile(hinf);
-- 
2.26.2




More information about the wine-devel mailing list