Escape texts in exported HTML (#429)

This commit is contained in:
Sascha Ißbrücker
2023-02-18 18:25:54 +01:00
committed by GitHub
parent 89a9271c71
commit 74134d3896
2 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
from django.test import TestCase
from bookmarks.services import exporter
from bookmarks.tests.helpers import BookmarkFactoryMixin
class ExporterTestCase(TestCase, BookmarkFactoryMixin):
def test_escape_html_in_title_and_description(self):
bookmark = self.setup_bookmark(
title='<style>: The Style Information element',
description='The <style> HTML element contains style information for a document, or part of a document.'
)
html = exporter.export_netscape_html([bookmark])
self.assertIn('&lt;style&gt;: The Style Information element', html)
self.assertIn(
'The &lt;style&gt; HTML element contains style information for a document, or part of a document.',
html
)
def test_handle_empty_values(self):
bookmark = self.setup_bookmark()
bookmark.title = ''
bookmark.description = ''
bookmark.website_title = None
bookmark.website_description = None
bookmark.save()
exporter.export_netscape_html([bookmark])