X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fmodules%2Fmod_svg%2Fsvg_parser.cpp;h=1a35849fca2840e8aa43d37c756e29f95881f21a;hb=16ad7837f0dd6c39091dbaa8f399b6f0b97e5f4f;hp=680aa4faefe508a94ceecf6b79a5187e2d8b6620;hpb=971a0a14a75d8f5b6e85a897c46cb702423aa7c8;p=synfig.git diff --git a/synfig-core/src/modules/mod_svg/svg_parser.cpp b/synfig-core/src/modules/mod_svg/svg_parser.cpp index 680aa4f..1a35849 100644 --- a/synfig-core/src/modules/mod_svg/svg_parser.cpp +++ b/synfig-core/src/modules/mod_svg/svg_parser.cpp @@ -1780,7 +1780,7 @@ Svg_parser::get_tokens_path(String path){ //mini path lexico-parser else if(a=='V'){ e=15; i++;} else if(a=='H'){ e=16; i++;} else if(a=='z' || a=='Z'){ e=17; i++;} - else if(a=='-' ||a=='.'|| isdigit (a)){ e=18;} + else if(a=='-' || a=='.' || a=='e' || a=='E' || isdigit (a)){ e=18;} else if(a==','){ e=19; i++;} else if(a==' '){i++;} break; @@ -1804,7 +1804,7 @@ Svg_parser::get_tokens_path(String path){ //mini path lexico-parser case 16: tokens.push_back("H"); e=0; break; case 17: tokens.push_back("z"); e=0; break;//loop - case 18: if(a=='-'||a=='.'|| isdigit (a)){ + case 18: if(a=='-' || a=='.' || a=='e' || a=='E' || isdigit (a)){ buffer.append(path.substr(i,1));i++; }else{ e=20; @@ -1853,6 +1853,8 @@ Svg_parser::randomLetter(){ int Svg_parser::getRed(String hex){ if(hex.at(0)=='#'){ + //allow for 3-digit hex codes (#rgb = #rrggbb) + if (hex.length()<7) return (16+1) * hextodec(hex.substr(1,1)); return hextodec(hex.substr(1,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1; @@ -1865,6 +1867,7 @@ Svg_parser::getRed(String hex){ int Svg_parser::getGreen(String hex){ if(hex.at(0)=='#'){ + if (hex.length()<7) return (16+1) * hextodec(hex.substr(2,1)); return hextodec(hex.substr(3,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1; @@ -1877,6 +1880,7 @@ Svg_parser::getGreen(String hex){ int Svg_parser::getBlue(String hex){ if(hex.at(0)=='#'){ + if (hex.length()<7) return (16+1) * hextodec(hex.substr(3,1)); return hextodec(hex.substr(5,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1;