File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class WangEditor :
2+ def __init__ (self ):
3+ self .html_content = ""
4+
5+ def set_html (self , html ):
6+ self .html_content = html
7+
8+ def get_html (self ):
9+ return self .html_content
10+
11+ def sanitize_html (self , html ):
12+ # Replace HTML ASCII character set with actual characters
13+ return html .replace ("&#" , "&" ).replace (";" , "" )
14+
15+ def test_wang_editor ():
16+ # Create an instance of WangEditor
17+ editor = WangEditor ()
18+
19+ # Set HTML content with ASCII character set
20+ editor .set_html ("Hello, world! & < > "" )
21+
22+ # Get the HTML content after sanitization
23+ sanitized_html = editor .get_html ()
24+
25+ # Expected output: "Hello, world! & < > \""
26+ assert sanitized_html == "Hello, world! & < > \" " , "HTML content is not sanitized correctly."
27+
28+ print ("Test passed: HTML content is sanitized correctly." )
29+
30+ # Run the test
31+ test_wang_editor ()
You can’t perform that action at this time.
0 commit comments