Skip to content

Minify closes <form> tag erroneously #134

@LuisFGomez

Description

@LuisFGomez

In my case, I have a form that's rendered inside a bootstrap 3 panel. Here's a simple example you can run through pyminify:

<html>
	<head></head>
	<body>
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>Perform this action?</h4>
			</div><!-- panel-heading -->
			<div class="panel-body">
				<p>Would you like to perform this action?</p>
				<form action="/some/url/" method="POST">
					<input name="csrfmiddlewaretoken" type="hidden" value="fakecsrftokenvalue"/>
					<input name="somekey" type="hidden" value="someval"/>
			</div><!-- panel-body -->
			<div class="panel-footer text-right">
				<div class="form-group">
					<input class="btn btn-primary" type="submit" value="Yes!"/>
				</div><!-- form-group -->
				</form>
			</div><!-- panel-footer -->
		</div><!-- panel -->
	</body>
</html>

The output is

<html><head></head><body><div class="panel panel-default"><div class="panel-heading"><h4>Perform this action?</h4></div><div class="panel-body"><p>Would you like to perform this action?</p><form action="/some/url/" method="POST"><input name="csrfmiddlewaretoken" type="hidden" value="fakecsrftokenvalue"/><input name="somekey" type="hidden" value="someval"/></form></div><div class="panel-footer text-right"><div class="form-group"><input class="btn btn-primary" type="submit" value="Yes!"/></div></div></div></body></html>

This places the closing </form> tag immediately after the second <input> tag, which excludes the submit button from the form. This breaks the form entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions