File kdelibs-fix-handling-of-arcs.patch of Package kdelibs3
diff -Naru kdelibs-3.5.10_orig/kdecore/svgicons/ksvgiconpainter.cpp kdelibs-3.5.10/kdecore/svgicons/ksvgiconpainter.cpp
--- kdelibs-3.5.10_orig/kdecore/svgicons/ksvgiconpainter.cpp 2022-05-19 09:45:35.596272064 +0900
+++ kdelibs-3.5.10/kdecore/svgicons/ksvgiconpainter.cpp 2022-05-19 13:58:12.214584961 +0900
@@ -1743,17 +1743,34 @@
double curx = 0.0, cury = 0.0, contrlx = 0.0, contrly = 0.0, xc, yc;
unsigned int lastCommand = 0;
- QString _d = value.replace(",", " ");
- _d = _d.simplifyWhiteSpace();
- const char *ptr = _d.latin1();
- const char *end = _d.latin1() + _d.length() + 1;
+ QCString _d = value.replace(",", " ").simplifyWhiteSpace().latin1();
+ const char *ptr = _d.data();
+ const char *end = _d.data() + _d.length();
double tox, toy, x1, y1, x2, y2, rx, ry, angle;
bool largeArc, sweep;
- char command = *(ptr++);
+ char command = *ptr;
while(ptr < end)
{
+
+ if(*ptr == '+' || *ptr == '-' || *ptr == '.' || (*ptr >= '0' && *ptr <= '9'))
+ {
+ // there are still coords in this command
+ if(command == 'M')
+ {
+ command = 'L';
+ }
+ else if(command == 'm')
+ {
+ command = 'l';
+ }
+ }
+ else
+ {
+ command = *(ptr++);
+ }
+
if(*ptr == ' ')
ptr++;
@@ -2179,10 +2196,19 @@
ptr = getCoord(ptr, rx);
ptr = getCoord(ptr, ry);
ptr = getCoord(ptr, angle);
- ptr = getCoord(ptr, tox);
- largeArc = tox == 1;
- ptr = getCoord(ptr, tox);
- sweep = tox == 1;
+ // 'largeArc' and 'sweep' are single digit flags. Some non conforming svg files do not
+ // separate those fields with separators, so we can't use getCoord() here.
+ // See TDE/tde issue #46 on TGW
+ largeArc = ((*ptr++) != '0');
+ while (*ptr == ' ')
+ {
+ ptr++;
+ }
+ sweep = ((*ptr++) != '0');
+ while (*ptr == ' ')
+ {
+ ptr++;
+ }
ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy);
@@ -2198,10 +2224,19 @@
ptr = getCoord(ptr, rx);
ptr = getCoord(ptr, ry);
ptr = getCoord(ptr, angle);
- ptr = getCoord(ptr, tox);
- largeArc = tox == 1;
- ptr = getCoord(ptr, tox);
- sweep = tox == 1;
+ // 'largeArc' and 'sweep' are single digit flags. Some non conforming svg files do not
+ // separate those fields with separators, so we can't use getCoord() here.
+ // See TDE/tde issue #46 on TGW
+ largeArc = ((*ptr++) != '0');
+ while (*ptr == ' ')
+ {
+ ptr++;
+ }
+ sweep = ((*ptr++) != '0');
+ while (*ptr == ' ')
+ {
+ ptr++;
+ }
ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy);
@@ -2215,17 +2250,6 @@
break;
}
- if(*ptr == '+' || *ptr == '-' || (*ptr >= '0' && *ptr <= '9') || (*ptr == '.'))
- {
- // there are still coords in this command
- if(command == 'M')
- command = 'L';
- else if(command == 'm')
- command = 'l';
- }
- else
- command = *(ptr++);
-
// Detect reflection points
if(lastCommand != 'C' && lastCommand != 'c' &&
lastCommand != 'S' && lastCommand != 's' &&