Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify closes <form> tag erroneously #134

Open
LuisFGomez opened this issue Jan 23, 2019 · 1 comment
Open

Minify closes <form> tag erroneously #134

LuisFGomez opened this issue Jan 23, 2019 · 1 comment

Comments

@LuisFGomez
Copy link

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.

@germn
Copy link

germn commented May 17, 2019

		<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 -->

panel-body must either be closed before form tag opened or after it is closed.
Otherwise it's undefined what's your html mean.
html parser can't nor shouldn't provide any guarantee for invalid html.

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

No branches or pull requests

2 participants