Skip to content

Add %HTML.Forms config directive#260

Merged
ezyang merged 1 commit into
ezyang:masterfrom
xemlock:master
Jun 29, 2020
Merged

Add %HTML.Forms config directive#260
ezyang merged 1 commit into
ezyang:masterfrom
xemlock:master

Conversation

@xemlock
Copy link
Copy Markdown
Contributor

@xemlock xemlock commented Jun 11, 2020

The %HTML.Forms directive enables Forms module regardless of the %HTML.Trusted value. This adds support for form elements without enabling other unsafe modules, such as Scripts, Iframe or Object.

To achieve the same effect without this directive one has to explicitly list all enabled modules in %HTML.AllowedModules, and any not listed will be removed. This however is not very convenient, as the allowed modules may vary between doctypes.

Resolves #213.

The %HTML.Forms directive enables Forms module regardless of the %HTML.Trusted
value. This adds support for form elements without enabling other unsafe
modules, such as Scripts, Iframe or Object.

To achieve the same effect without this directive one has to explicitly list
all enabled modules in %HTML.AllowedModules, and any not listed will be
removed. This however is not very convenient, as the allowed modules may vary
between doctypes.

Resolves ezyang#213.
@ezyang ezyang merged commit 3bdc031 into ezyang:master Jun 29, 2020
@glensc
Copy link
Copy Markdown

glensc commented Jun 29, 2020

@xemlock can you post an example in regards #213 how this is supposed to be used?

i.e currently I have:

@xemlock
Copy link
Copy Markdown
Contributor Author

xemlock commented Jun 29, 2020

Hi @glensc,
It should be sufficient to replace these lines in your example:

$config->set('HTML.Trusted', true);
$config->set('HTML.ForbiddenElements', ['script', 'noscript']);

with the following:

$config->set('HTML.Forms', true);

I'm also currently working on another PR that would allow you to narrow the allowed input types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Whitelist <input type=checkbox> only

3 participants