prefilters: fix crash due to class being a string not list #173
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some tags can be either a str or a list which can cause a crash in the existing filters.
https://beautiful-soup-4.readthedocs.io/en/latest/index.html?highlight=find_all#multi-valued-attributes
Traceback (most recent call last):
File "/var/home/andrew/Projects/web/wagtail-example/mysite/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
utility.execute()
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/django/core/management/init.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/management/commands/import_xml.py", line 71, in handle
importer.run(
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/importers/wordpress.py", line 125, in run
wp_post_id=wordpress_item.cleaned_data.get("wp_post_id")
File "/usr/lib/python3.10/functools.py", line 981, in get
val = self.func(instance)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/importers/wordpress.py", line 530, in cleaned_data
"body": self.body_stream_field(self.prefilter_content(self.raw_body)),
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/importers/wordpress.py", line 373, in prefilter_content
cached_result = function(cached_result, filter.get("OPTIONS"))
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/prefilters/transform_styles_filter.py", line 104, in filter_transform_inline_styles
filter_transform_styles(
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/prefilters/transform_styles_filter.py", line 123, in filter_transform_styles
filter_method(soup, tag)
File "/var/home/andrew/Projects/web/wagtail-example/mysite/env/lib/python3.10/site-packages/wagtail_wordpress_import/prefilters/transform_styles_defaults.py", line 68, in transform_float_left
tag.attrs["class"].append("float-left")
AttributeError: 'str' object has no attribute 'append'
(Description)
Ticket URL:
Testing
Documentation.