svg_loader: <image> tag introduced fix #9

Fixed Base64 and utf8 for new line and whitespace
Changed tvgSvgLoaderCommon.h to single line convention
This commit is contained in:
Michal Maciola 2021-07-08 10:49:21 +02:00 committed by Hermet Park
parent 28342c5c1f
commit 31f45fbd5f
2 changed files with 11 additions and 4 deletions

View file

@ -190,10 +190,7 @@ struct SvgLineNode
struct SvgImageNode struct SvgImageNode
{ {
float x; float x, y, w, h;
float y;
float w;
float h;
string *href; string *href;
}; };

View file

@ -269,6 +269,11 @@ string svgUtilURLDecode(const char *src)
char a, b; char a, b;
while (*src) { while (*src) {
if (*src <= 0x20) {
++src;
continue;
}
if (*src == '%' && if (*src == '%' &&
((a = src[1]) && (b = src[2])) && ((a = src[1]) && (b = src[2])) &&
(isxdigit(a) && isxdigit(b))) { (isxdigit(a) && isxdigit(b))) {
@ -293,6 +298,11 @@ string svgUtilBase64Decode(const char *src)
decoded.reserve(3*(1+(length >> 2))); decoded.reserve(3*(1+(length >> 2)));
while (*src && *(src+1)) { while (*src && *(src+1)) {
if (*src <= 0x20) {
++src;
continue;
}
auto value1 = _base64Value(src[0]); auto value1 = _base64Value(src[0]);
auto value2 = _base64Value(src[1]); auto value2 = _base64Value(src[1]);
decoded += (value1 << 2) + ((value2 & 0x30) >> 4); decoded += (value1 << 2) + ((value2 & 0x30) >> 4);