-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
9 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
document_page_history = env["document.page.history"] | ||
for record in document_page_history.search([]): | ||
# Apply default HTML sanitize by reassigning the content | ||
record.content = record.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
document_page/tests/test_document_page_content_sanitized.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from odoo.tests import common | ||
|
||
|
||
class TestDocumentContentSanitized(common.TransactionCase): | ||
def setUp(self): | ||
super(TestDocumentContentSanitized, self).setUp() | ||
self.page_obj = self.env["document.page"] | ||
self.category1 = self.env.ref("document_page.demo_category1") | ||
|
||
def test_page_content_sanitized(self): | ||
malicious_page = self.page_obj.create( | ||
{ | ||
"name": "Malicious Page", | ||
"parent_id": self.category1.id, | ||
"content": "<p>Test content</p><script> alert(1)</script>", | ||
} | ||
) | ||
self.assertEqual(malicious_page.content, "<p>Test content</p>") | ||
|
||
malicious_page.write( | ||
{"content": "<p>Test content</p><script> alert(1)</script>"} | ||
) | ||
|
||
self.assertEqual(malicious_page.content, "<p>Test content</p>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters