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

Flattening an attribute value fails to quote it satisfactorily #111

Open
jonathanj opened this issue Apr 1, 2021 · 4 comments
Open

Flattening an attribute value fails to quote it satisfactorily #111

jonathanj opened this issue Apr 1, 2021 · 4 comments

Comments

@jonathanj
Copy link
Contributor

Adjusting the value in the attribute tests to include a double quote in the rendered value.

--- a/nevow/test/test_newflat.py
+++ b/nevow/test/test_newflat.py
@@ -478,7 +478,7 @@ class FlattenTests(TestCase, FlattenMixin):
         which was returned by L{IRenderable.render} is replaced with the result
         of the named renderer on the L{IRenderable} which returned the L{Tag}.
         """
-        result = "quux"
+        result = 'qu"ux'
         renders = []
         request = object()
         tag = div(foo=invisible(render="bar"))

Yields this test failure:

twisted.trial.unittest.FailTest: '<div foo="qu"ux"></div>' != '<div foo="quux"></div>'

nevow.test.test_newflat.FlattenTests.test_renderAttributeNestedInAttributeValue

Resilient HTML parsers are able to parse this output but the results are mangled in the vein of <div foo="qu" ux="">. XHTML parsers (such as in use by Athena) refuse to parse this output altogether.

This issue became apparent when trying to render a value with double-quotes into the value attribute of an input element.

@jonathanj
Copy link
Contributor Author

Brief investigation indicates that the inAttribute flag is not propagated (either from WovenContext or from nested _flatten calls) in the render-directive case, preventing the inAttribute case of escapedData from being used.

@wthie
Copy link
Contributor

wthie commented Apr 1, 2021

Just out of curiosity - can this be reproduced in Python 2? If not then the problem might be in one of the changes introduced by porting to Python 3.

@jonathanj
Copy link
Contributor Author

@wthie Sorry I should have mentioned that this was discovered and reproduced on Python 2.

@wthie
Copy link
Contributor

wthie commented Apr 2, 2021

No problem, there was another flattener problem recently on the twisted mailing list, flattening still seems to be a tricky thing. I only have very simple use cases for flattening but will look into the problem when starting the chunking of the Python3 port.

@mithrandi mithrandi pinned this issue Apr 4, 2021
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