From eaeccc3c3a87db70b8ab53866956cb9a5cecc8d6 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 24 Jul 2013 14:24:33 -0400 Subject: [PATCH] enforce valid hsla values - refs #1954 --- include/mapnik/image_filter_types.hpp | 14 +++++++++++++- .../data/broken_maps/invalid-scale-hsla-filter.xml | 4 ++++ ...er-with-background-image-and-hsla-transform.xml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/data/broken_maps/invalid-scale-hsla-filter.xml diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index e5f0b5db6..f6918dccd 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -26,13 +26,17 @@ // mapnik #include #include +#include + // boost #include + // stl #include #include #include // for std::back_insert_iterator + namespace mapnik { namespace filter { struct blur {}; @@ -66,7 +70,15 @@ struct scale_hsla l0(_l0), l1(_l1), a0(_a0), - a1(_a1) {} + a1(_a1) { + if (h0 < 0 || h1 > 1 || + s0 < 0 || s1 > 1 || + l0 < 0 || l1 > 1 || + a0 < 0 || a1 > 1) + { + throw config_error("scale-hsla values must be between 0 and 1"); + } + } inline bool is_identity() const { return (h0 == 0 && h1 == 1 && diff --git a/tests/data/broken_maps/invalid-scale-hsla-filter.xml b/tests/data/broken_maps/invalid-scale-hsla-filter.xml new file mode 100644 index 000000000..fec9d9eb0 --- /dev/null +++ b/tests/data/broken_maps/invalid-scale-hsla-filter.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml index 4d691fbaa..96a0756a3 100644 --- a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml +++ b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml @@ -1,7 +1,7 @@