Skip to content

Commit

Permalink
Replace attr type aliases with explicit AttrDef instances
Browse files Browse the repository at this point in the history
This reduces api surface area.

Removed type aliases: Integer, Float and Datetime.
  • Loading branch information
xemlock committed Nov 16, 2022
1 parent 1c228b1 commit 0105fef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
8 changes: 0 additions & 8 deletions library/HTMLPurifier/HTML5Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ public static function setupHTMLDefinition(HTMLPurifier_HTMLDefinition $def, HTM
// one provided with 4.6.0
$def->manager->attrTypes->set('Bool', new HTMLPurifier_AttrDef_HTML_Bool2());

// Add missing definition for Integer, required by tabindex
$def->manager->attrTypes->set('Integer', new HTMLPurifier_AttrDef_Integer());

// Add support for Floating point number attributes
$def->manager->attrTypes->set('Float', new HTMLPurifier_AttrDef_HTML5_Float());

$def->manager->attrTypes->set('Datetime', new HTMLPurifier_AttrDef_HTML5_Datetime());

return $def;
}
}
5 changes: 4 additions & 1 deletion library/HTMLPurifier/HTMLModule/HTML5/CommonAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public function setup($config)
'id' => 'ID',
'title' => 'CDATA',
// tabindex attribute is supported on all elements (global attributes)
'tabindex' => 'Integer',
// Built-in 'Number' type can't be used here, as it only allows positive integers.
// Any integer is a valid tabindex value, also negative values are not dangerous
// per se, although their presence may affect a11y.
'tabindex' => new HTMLPurifier_AttrDef_Integer(),
// Final spec for inputmode global attribute has been published on 15 Dec 2017
// https://web.archive.org/web/20171215142138/https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute
// The 'none' value has been intentionally omitted from the list of
Expand Down
4 changes: 2 additions & 2 deletions library/HTMLPurifier/HTMLModule/HTML5/SafeForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function setup($config)
'Inline',
'Common',
array(
'value' => 'Float#min:0',
'max' => 'Float#min:0',
'value' => new HTMLPurifier_AttrDef_HTML5_Float(array('min' => 0)),
'max' => new HTMLPurifier_AttrDef_HTML5_Float(array('min' => 0)),
)
);
$progress->excludes = array('progress' => true);
Expand Down

0 comments on commit 0105fef

Please sign in to comment.