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

clean can randomize attribute order #121

Closed
trainiac opened this issue Mar 19, 2014 · 3 comments · Fixed by #137
Closed

clean can randomize attribute order #121

trainiac opened this issue Mar 19, 2014 · 3 comments · Fixed by #137

Comments

@trainiac
Copy link

import bleach

bleach.clean('<iframe height="315" src="//www.youtube.com/embed/qdJp5-g69go" width="560"></iframe>', tags=allowed_tags, attributes=allowed_attributes, styles=allowed_styles)

# outputs 
# <iframe src="//www.youtube.com/embed/qdJp5-g69go" width="560" height="315"></iframe>

# would be nice to have
# <iframe height="315" src="//www.youtube.com/embed/qdJp5-g69go" width="560"></iframe>
@trainiac
Copy link
Author

Main reason this is an issue is because it makes unit testing a little trickier.

@jsocol
Copy link
Contributor

jsocol commented Mar 19, 2014

See also #109.

#109 is difficult to fix, but replacing the attribute dict with an OrderedDict would probably not be, which may be a decent partial solution.

@msabramo
Copy link
Contributor

Just ran into this as well while working on pypa/readme_renderer#3.

[marca@marca-mac2 readme]$ tox --hashseed=3142166842 -e py27 -- -k test_rst_008 --tb=short
GLOB sdist-make: /Users/marca/dev/git-repos/readme/setup.py
py27 inst-nodeps: /Users/marca/dev/git-repos/readme/.tox/dist/readme-0.3.0.zip
py27 runtests: PYTHONHASHSEED='3142166842'
py27 runtests: commands[0] | py.test -k test_rst_008 --tb=short
============================================================================= test session starts ==============================================================================
platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4
plugins: capturelog, cov
collected 8 items

tests/test_rst.py F

=================================================================================== FAILURES ===================================================================================
_________________________________________________________________________________ test_rst_008 _________________________________________________________________________________
tests/test_rst.py:39: in test_rst_008
    _do_test_with_files('test_rst_008')
tests/test_rst.py:49: in _do_test_with_files
    assert out == expected_html
E   assert '<p>Here is s...nkey</a></p>\n' == '<p>Here is so...nkey</a></p>\n'
E     Skipping 1352 identical leading characters in diff, use -v to show
E     -  click <a href="http://www.surveymonkey.com" rel="nofollow">SurveyMonkey</a></p>
E     ?                                             ---------------
E     +  click <a rel="nofollow" href="http://www.surveymonkey.com">SurveyMonkey</a></p>
E     ?          +++++++++++++++
==================================================================== 7 tests deselected by '-ktest_rst_008' ====================================================================
==================================================================== 1 failed, 7 deselected in 0.41 seconds ====================================================================
ERROR: InvocationError: '/Users/marca/dev/git-repos/readme/.tox/py27/bin/py.test -k test_rst_008 --tb=short'
___________________________________________________________________________________ summary ____________________________________________________________________________________
ERROR:   py27: commands failed
[marca@marca-mac2 readme]$ tox --hashseed=1651908909 -e py27 -- -k test_rst_008 --tb=short
GLOB sdist-make: /Users/marca/dev/git-repos/readme/setup.py
py27 inst-nodeps: /Users/marca/dev/git-repos/readme/.tox/dist/readme-0.3.0.zip
py27 runtests: PYTHONHASHSEED='1651908909'
py27 runtests: commands[0] | py.test -k test_rst_008 --tb=short
============================================================================= test session starts ==============================================================================
platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4
plugins: capturelog, cov
collected 8 items

tests/test_rst.py .

==================================================================== 7 tests deselected by '-ktest_rst_008' ====================================================================
==================================================================== 1 passed, 7 deselected in 0.37 seconds ====================================================================
___________________________________________________________________________________ summary ____________________________________________________________________________________
  py27: commands succeeded
  congratulations :)

msabramo added a commit to msabramo/bleach that referenced this issue Dec 12, 2014
msabramo added a commit to msabramo/bleach that referenced this issue Dec 12, 2014
by passing `alphabetical_attributes=True` to
`html5lib.serializer.HTMLSerializer`

Fixes: mozillaGH-121
msabramo added a commit to msabramo/bleach that referenced this issue Dec 12, 2014
by passing `alphabetical_attributes=True` to
`html5lib.serializer.HTMLSerializer`

Fixes: mozillaGH-121
@jsocol jsocol closed this as completed in ccccfdd Dec 12, 2014
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 a pull request may close this issue.

3 participants