/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const RULENAME="oj-html-no-style";const DESCRIPTION="HTML &lt;style&gt; sections or 'style' attributes are not permitted.";const SHORT_DESCRIPTION="Cannot use in-line CSS styles.";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}constructor(){this._opts={section:true,attribute:false}}register(regCtx){if(!this._getRuleOptions(regCtx)){return false}let reg={};if(this._opts.section){reg["<style>"]=this._onStyle}if(this._opts.attribute){reg["style"]=this._onAttr}return reg}_onStyle(ruleCtx){if(!this._checkCsp(ruleCtx)){let issue=new ruleCtx.Issue("<style> section is not permitted.");ruleCtx.reporter.addIssue(issue,ruleCtx)}}_onAttr(ruleCtx){if(!this._checkCsp(ruleCtx)){let issue=new ruleCtx.Issue("'style' attribute is not permitted");ruleCtx.reporter.addIssue(issue,ruleCtx)}}_getRuleOptions(regCtx){var ret=true;var opts;if(opts=regCtx.ruleOpts.customOpts){if(opts=opts.criteria){if(regCtx.utils.utils.isObject(opts)){this._opts.section=!!opts.section;this._opts.attribute=!!opts.attribute;ret=opts.section||opts.attribute}}}return ret}_checkCsp(ruleCtx){if(!this._cspCheck){this._cspRule=ruleCtx.rulePack.isRuleEnabled("csp-html-style-unsafe-inline","CSP");this._cspCheck=true}return this._cspRule}}module.exports=Rule;