]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In ieee1284NormalizeMakeAndModel() fix parsing device IDs
authorTill Kamppeter <till.kamppeter@gmail.com>
Fri, 22 Oct 2021 19:20:52 +0000 (21:20 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Fri, 22 Oct 2021 19:20:52 +0000 (21:20 +0200)
Some IEEE-1284 device IDs have spaces before and after the
manufacturer and model names. These need to be removed when generating
make-and-model strings for display, sorting, ... THis especially leads
to duplicate manufacturer names (extra mention of manufacturer in
model name) not being recognized and removed.

cupsfilters/ieee1284.c

index ed0e52979a1762f927d80c91c4b7acbd7e0701cf..1bcbeddcc6200c5734ef105cd10a9b93b2bdd2de 100644 (file)
@@ -787,6 +787,7 @@ ieee1284NormalizeMakeAndModel(
     bufptr = buffer;
     while (*makeptr != ':') makeptr ++;
     makeptr ++;
+    while (isspace(*makeptr)) makeptr ++;
     while (*makeptr != ';' && *makeptr != '\0' &&
           bufptr < buffer + bufsize - 1)
     {
@@ -794,6 +795,7 @@ ieee1284NormalizeMakeAndModel(
       makeptr ++;
       bufptr ++;
     }
+    while (isspace(*(bufptr - 1))) bufptr --;
     if (bufptr < buffer + bufsize - 1)
     {
       *bufptr = ' ';
@@ -803,6 +805,7 @@ ieee1284NormalizeMakeAndModel(
     makeptr = bufptr;
     while (*modelptr != ':') modelptr ++;
     modelptr ++;
+    while (isspace(*modelptr)) modelptr ++;
     while (*modelptr != ';' && *modelptr != '\0' &&
           bufptr < buffer + bufsize - 1)
     {
@@ -810,6 +813,7 @@ ieee1284NormalizeMakeAndModel(
       modelptr ++;
       bufptr ++;
     }
+    while (isspace(*(bufptr - 1))) bufptr --;
     *bufptr = '\0';
     if (!nomakemodel && makeptr != bufptr)
       modelptr = makeptr;