enforce valid hsla values - refs #1954

This commit is contained in:
Dane Springmeyer 2013-07-24 14:24:33 -04:00
parent 7c63b666f9
commit eaeccc3c3a
3 changed files with 18 additions and 2 deletions

View file

@ -26,13 +26,17 @@
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
#include <mapnik/config_error.hpp>
// boost // boost
#include <boost/variant.hpp> #include <boost/variant.hpp>
// stl // stl
#include <vector> #include <vector>
#include <ostream> #include <ostream>
#include <iterator> // for std::back_insert_iterator #include <iterator> // for std::back_insert_iterator
namespace mapnik { namespace filter { namespace mapnik { namespace filter {
struct blur {}; struct blur {};
@ -66,7 +70,15 @@ struct scale_hsla
l0(_l0), l0(_l0),
l1(_l1), l1(_l1),
a0(_a0), 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 { inline bool is_identity() const {
return (h0 == 0 && return (h0 == 0 &&
h1 == 1 && h1 == 1 &&

View file

@ -0,0 +1,4 @@
<Map>
<Style name="style" image-filters="scale-hsla(-1,1.1,0,1,0,1,0,1)">
</Style>
</Map>

View file

@ -1,7 +1,7 @@
<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" background-image="../../data/images/checker.jpg"> <Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" background-image="../../data/images/checker.jpg">
<Style name="ellipse" <Style name="ellipse"
direct-image-filters=" scale-hsla(0,1,0,1,0,1,0,.5)" direct-image-filters="scale-hsla(0,1,0,1,0,1,0,.5)"
image-filters="scale-hsla(.1,.9,.5,1,.5,1,.2,1)" image-filters="scale-hsla(.1,.9,.5,1,.5,1,.2,1)"
> >
<Rule> <Rule>