Skip to content

Commit 5d3b4b3

Browse files
committed
Implement bounds checking for adjust-color arguments
1 parent d49c338 commit 5d3b4b3

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/functions.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -686,18 +686,25 @@ namespace Sass {
686686
error("cannot specify both RGB and HSL values for `adjust-color`", pstate);
687687
}
688688
if (rgb) {
689+
double rr = r ? ARGR("$red", Number, -255, 255)->value() : 0;
690+
double gg = g ? ARGR("$green", Number, -255, 255)->value() : 0;
691+
double bb = b ? ARGR("$blue", Number, -255, 255)->value() : 0;
692+
double aa = a ? ARGR("$alpha", Number, -1, 1)->value() : 0;
689693
return new (ctx.mem) Color(pstate,
690-
color->r() + (r ? r->value() : 0),
691-
color->g() + (g ? g->value() : 0),
692-
color->b() + (b ? b->value() : 0),
693-
color->a() + (a ? a->value() : 0));
694+
color->r() + rr,
695+
color->g() + gg,
696+
color->b() + bb,
697+
color->a() + aa);
694698
}
695699
if (hsl) {
696700
HSL hsl_struct = rgb_to_hsl(color->r(), color->g(), color->b());
701+
double ss = s ? ARGR("$saturation", Number, -100, 100)->value() : 0;
702+
double ll = l ? ARGR("$lightness", Number, -100, 100)->value() : 0;
703+
double aa = a ? ARGR("$alpha", Number, -1, 1)->value() : 0;
697704
return hsla_impl(hsl_struct.h + (h ? h->value() : 0),
698-
hsl_struct.s + (s ? s->value() : 0),
699-
hsl_struct.l + (l ? l->value() : 0),
700-
color->a() + (a ? a->value() : 0),
705+
hsl_struct.s + ss,
706+
hsl_struct.l + ll,
707+
color->a() + aa,
701708
ctx,
702709
pstate);
703710
}

0 commit comments

Comments
 (0)