checkedArbitraryValue function

String checkedArbitraryValue(
  1. JxClassToken token
)

Valeur arbitraire décodée de token, après contrôle de sécurité.

Lève une JxRuleException si la valeur pourrait sortir de sa déclaration CSS (;, {, }, <…) ou charger du code (javascript:…). Ce contrôle double celui du parseur : il protège aussi les tokens construits à la main.

Implementation

String checkedArbitraryValue(JxClassToken token) {
  final value = token.arbitraryValue!.trim();
  final reason = JxCssValue.unsafeReason(value);
  if (reason != null) {
    throw JxRuleException(
      'Arbitrary value rejected for "${token.raw}": $reason.',
    );
  }
  return value;
}