summaryrefslogtreecommitdiffstats
path: root/src/svg/svg-length.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg/svg-length.cpp')
-rw-r--r--src/svg/svg-length.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index ea438e91a..bb6cc5428 100644
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
@@ -285,6 +285,10 @@ std::vector<SVGLength> sp_svg_length_list_read(gchar const *str)
static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next)
{
+/* note: this function is sometimes fed a string with several consecutive numbers, e.g. by sp_svg_length_list_read.
+So after the number, the string does not necessarily have a \0 or a unit, it might also contain a space or comma and then the next number!
+*/
+
if (!str) {
return 0;
}
@@ -330,8 +334,8 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*next = (char *) e + 1;
}
return 1;
- } else if (g_ascii_isspace(e[0])) {
- return 0; // spaces are not allowed
+ } else if (g_ascii_isspace(e[0]) && e[1] && g_ascii_isalpha(e[1])) {
+ return 0; // spaces between value and unit are not allowed
} else {
/* Unitless */
if (unit) {
@@ -367,7 +371,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PT;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "pt", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "pt", "px");
}
break;
case UVAL('p','c'):
@@ -375,7 +379,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PC;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "pc", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "pc", "px");
}
break;
case UVAL('m','m'):
@@ -383,7 +387,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::MM;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "mm", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "mm", "px");
}
break;
case UVAL('c','m'):
@@ -391,7 +395,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::CM;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "cm", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "cm", "px");
}
break;
case UVAL('i','n'):
@@ -399,7 +403,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::INCH;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "in", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "in", "px");
}
break;
case UVAL('f','t'):
@@ -407,7 +411,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::FOOT;
}
if (computed) {
- *computed = v * Inkscape::Util::Quantity::convert(1, "ft", "px");
+ *computed = Inkscape::Util::Quantity::convert(v, "ft", "px");
}
break;
case UVAL('e','m'):