From: joncruz Date: Sun, 27 Sep 2009 04:19:01 +0000 (+0000) Subject: Updated allowed icc-profile names to match recent grammars. Follow-up for bug #405143 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fac1e803300de05ddcf08e45de0b8a24c1858e70;p=inkscape.git Updated allowed icc-profile names to match recent grammars. Follow-up for bug #405143 --- diff --git a/src/svg/svg-color-test.h b/src/svg/svg-color-test.h index 49af63a5d..a540d4b1b 100644 --- a/src/svg/svg-color-test.h +++ b/src/svg/svg-color-test.h @@ -87,6 +87,8 @@ public: {1, true, "positive", "icc-color(positive, +0.1)"}, {1, true, "negative", "icc-color(negative, -0.1)"}, {0, false, "", "icc-color(named, value)"}, + {1, true, "hyphen-name", "icc-color(hyphen-name, 1)"}, + {1, true, "under_name", "icc-color(under_name, 1)"}, }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 9040d6e43..a8e24c311 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -454,7 +454,11 @@ sp_svg_create_color_hash() return colors; } - +/* + * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj + * Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z' + * Allowed ASCII remaining chars add: '-', '.', '0'-'9', + */ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor* dest ) { bool good = true; @@ -484,11 +488,14 @@ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor } if ( !g_ascii_isalpha(*str) - && ( !(0x080 & *str) ) ) { + && ( !(0x080 & *str) ) + && (*str != '_') + && (*str != ':') ) { // Name must start with a certain type of character good = false; } else { - while ( g_ascii_isdigit(*str) || g_ascii_isalpha(*str) || (*str == '-') ) { + while ( g_ascii_isdigit(*str) || g_ascii_isalpha(*str) + || (*str == '-') || (*str == ':') || (*str == '_') || (*str == '.') ) { if ( dest ) { dest->colorProfile += *str; } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 105d220a9..7e31b874a 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -397,7 +397,7 @@ static void sanitizeName( Glib::ustring& str ) && ((val < 'a') || (val > 'z')) && (val != '_') && (val != ':')) { - str.replace(0, 1, "_"); + str.replace(0, 1, "-"); } for (Glib::ustring::size_type i = 1; i < str.size(); i++) { char val = str.at(i); @@ -408,7 +408,7 @@ static void sanitizeName( Glib::ustring& str ) && (val != ':') && (val != '-') && (val != '.')) { - str.replace(i, 1, "_"); + str.replace(i, 1, "-"); } } }