@@ -134,29 +134,6 @@ class HTMLValidator:
134
134
'sub' , 'summary' , 'sup' , 'table' , 'tbody' , 'td' , 'template' , 'textarea' , 'time' , 'tfoot' , 'th' ,
135
135
'thead' , 'tr' , 'track' , 'tt' , 'u' , 'ul' , 'var' , 'video' , 'noscript' , 'wbr' ]
136
136
137
- acceptable_attributes = ['abbr' , 'accept' , 'accept-charset' , 'accesskey' ,
138
- 'action' , 'align' , 'allow' , 'allowfullscreen' , 'allowpaymentrequest' , 'alt' , 'as' , 'autoplay' , 'autocapitalize' , 'autocomplete' , 'autofocus' , 'autoplay' , 'axis' ,
139
- 'background' , 'balance' , 'bgcolor' , 'bgproperties' , 'border' ,
140
- 'bordercolor' , 'bordercolordark' , 'bordercolorlight' , 'bottompadding' ,
141
- 'cellpadding' , 'cellspacing' , 'ch' , 'challenge' , 'char' , 'charoff' ,
142
- 'choff' , 'charset' , 'checked' , 'cite' , 'class' , 'clear' , 'color' , 'cols' ,
143
- 'colspan' , 'compact' , 'contenteditable' , 'coords' , 'crossorigin' , 'data' , 'datafld' ,
144
- 'datapagesize' , 'datasrc' , 'datetime' , 'decoding' , 'default' , 'delay' , 'dir' , 'dirname' ,
145
- 'disabled' , 'download' , 'draggable' , 'dynsrc' , 'enctype' ,'end' , 'enterkeyhint' , 'face' , 'for' ,
146
- 'form' , 'formenctype' , 'frame' , 'galleryimg' , 'gutter' , 'headers' , 'height' , 'hidefocus' ,
147
- 'hidden' , 'high' , 'href' , 'hreflang' , 'hspace' , 'icon' , 'id' , 'inputmode' ,
148
- 'is' , 'ismap' , 'itemid' , 'itemprop' , 'itemref' , 'itemscope' , 'itemtype' , 'kind' ,'keytype' , 'label' , 'lang' , 'leftspacing' , 'loading' , 'list' , 'longdesc' ,
149
- 'loop' , 'loopcount' , 'loopend' , 'loopstart' , 'low' , 'lowsrc' , 'max' ,
150
- 'maxlength' , 'media' , 'method' , 'min' , 'minlength' , 'multiple' , 'muted' , 'name' , 'nohref' , 'nonce' ,
151
- 'noshade' , 'nowrap' , 'open' , 'optimum' , 'pattern' , 'ping' , 'placeholder' , 'playsinline' , 'point-size' , 'poster' , 'preload' ,
152
- 'prompt' , 'pqg' , 'radiogroup' , 'readonly' , 'referrerpolicy' , 'rel' , 'repeat-max' ,
153
- 'repeat-min' , 'replace' , 'required' , 'rev' , 'reversed' , 'rightspacing' , 'rows' ,
154
- 'rowspan' , 'rules' , 'scope' , 'selected' , 'shape' , 'size' , 'sizes' , 'span' , 'spellcheck' , 'src' ,
155
- 'srclang' , 'srcset' ,
156
- 'start' , 'step' , 'summary' , 'suppress' , 'tabindex' , 'target' , 'template' ,
157
- 'title' , 'toppadding' , 'translate' , 'type' , 'unselectable' , 'usemap' , 'urn' , 'valign' ,
158
- 'value' , 'variable' , 'volume' , 'vspace' , 'vrml' , 'width' , 'wrap' ,
159
- 'xml:lang' , 'xmlns' ]
160
137
161
138
acceptable_css_properties = ['azimuth' , 'background' , 'background-color' ,
162
139
'border' , 'border-bottom' , 'border-bottom-color' , 'border-bottom-style' ,
@@ -280,10 +257,8 @@ def handle_tag(self, tag, attributes, text):
280
257
if name .lower () == 'style' :
281
258
for evil in checkStyle (value ):
282
259
self .log (DangerousStyleAttr ({"parent" :self .element .parent .name , "element" :self .element .name , "attr" :"style" , "value" :evil }))
283
- elif name .lower () not in self .acceptable_attributes :
284
- # data-* attributes are acceptable
285
- if name .lower ()[:5 ] != "data-" :
286
- self .log (SecurityRiskAttr ({"parent" :self .element .parent .name , "element" :self .element .name , "attr" :name }))
260
+ elif name .lower ().startswith ("on" ):
261
+ self .log (SecurityRiskAttr ({"parent" :self .element .parent .name , "element" :self .element .name , "attr" :name }))
287
262
288
263
289
264
#
@@ -321,7 +296,7 @@ def startElementNS(self, name, qname, attrs):
321
296
if attr [1 ].lower () == 'style' :
322
297
for value in checkStyle (attrs .get (attr )):
323
298
self .log (DangerousStyleAttr ({"parent" :self .parent .name , "element" :self .name , "attr" :attr [1 ], "value" :value }))
324
- elif attr [1 ].lower () not in HTMLValidator . acceptable_attributes :
299
+ elif attr [1 ].lower (). startswith ( "on" ) :
325
300
self .log (SecurityRiskAttr ({"parent" :self .parent .name , "element" :self .name , "attr" :attr [1 ]}))
326
301
self .push (htmlEater (), self .name , attrs )
327
302
if name .lower () not in HTMLValidator .acceptable_elements :
0 commit comments