mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-52724 editor_atto: Scrub atto html for invalid ol, ul, and li tags
Try to correct broken ul/ol/li tags, as they have an outsized impact on course layout. Uses basic regex and loops to track open and closed tags. Also adds a deep clean option to the HTML cleaner, that runs less frequent, more intensive cleanings. This is because normally _cleanHTML gets called after each keystroke, which could cause problems with large content on weak systems. Behat changes are a fix for setting multiline strings in Atto, and creating a multiline match step.
- Loading branch information
1 parent
18aafd0
commit 59704c6
Showing
8 changed files
with
919 additions
and
17 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,169 @@ | ||
@editor @editor_atto @atto @editor_moodleform | ||
Feature: Atto HTML cleanup. | ||
In order to test html cleaning functionality, I write in a HTML atto text field. | ||
|
||
@javascript | ||
Scenario: Extra UL close and orphan LI items | ||
Given I log in as "admin" | ||
When I open my profile in edit mode | ||
And I click on "Show more buttons" "button" | ||
And I click on "HTML" "button" | ||
And I set the field "Description" to multiline: | ||
""" | ||
<li>A</li> | ||
<li>B</li> | ||
</ol> | ||
<ul> | ||
<li>C</li> | ||
</ul></ul> | ||
<li class="someclass ul UL">D</li> | ||
<li>E</li> | ||
""" | ||
And I click on "HTML" "button" | ||
Then the field "Description" matches multiline: | ||
""" | ||
<ol><li>A</li> | ||
<li>B</li> | ||
</ol> | ||
<ul> | ||
<li>C</li> | ||
</ul> | ||
<ul><li class="someclass ul UL">D</li> | ||
<li>E</li></ul> | ||
""" | ||
|
||
@javascript | ||
Scenario: Missing LI close tags, extra closing OL, missing closing UL tag | ||
Given I log in as "admin" | ||
When I open my profile in edit mode | ||
And I click on "Show more buttons" "button" | ||
And I click on "HTML" "button" | ||
And I set the field "Description" to multiline: | ||
""" | ||
<div class="ol"><ol> | ||
<li>A</li> | ||
<li>B | ||
</ol></div> | ||
<ul> | ||
<li>C | ||
<li>D</li> | ||
</ol> | ||
""" | ||
And I click on "HTML" "button" | ||
Then the field "Description" matches multiline: | ||
""" | ||
<div class="ol"><ol> | ||
<li>A</li> | ||
<li>B | ||
</li></ol></div> | ||
<ul> | ||
<li>C | ||
</li><li>D</li></ul> | ||
""" | ||
|
||
@javascript | ||
Scenario: Missing beginning OL tag, empty LI close tag | ||
Given I log in as "admin" | ||
When I open my profile in edit mode | ||
And I click on "Show more buttons" "button" | ||
And I click on "HTML" "button" | ||
And I set the field "Description" to multiline: | ||
""" | ||
<p>Before</p> | ||
<li>A</li></li> | ||
<li>B</li> | ||
</ol> | ||
<p>After</p> | ||
<ul data-info="UL ul OL ol"> | ||
<ul> | ||
C</li> | ||
<li>D</li> | ||
<li>E | ||
</ul> | ||
</ul><ul> | ||
<p>After 2</p> | ||
""" | ||
And I click on "HTML" "button" | ||
Then the field "Description" matches multiline: | ||
""" | ||
<p>Before</p> | ||
<ol><li>A</li> | ||
<li>B</li> | ||
</ol> | ||
<p>After</p> | ||
<ul data-info="UL ul OL ol"> | ||
<ul><li> | ||
C</li> | ||
<li>D</li> | ||
<li>E | ||
</li></ul> | ||
</ul> | ||
<p>After 2</p> | ||
""" | ||
|
||
@javascript | ||
Scenario: Random close LI tag, extra LI open tag, missing OL tag | ||
Given I log in as "admin" | ||
When I open my profile in edit mode | ||
And I click on "Show more buttons" "button" | ||
And I click on "HTML" "button" | ||
And I set the field "Description" to multiline: | ||
""" | ||
<p>Before</p></li><ul> | ||
<ul> | ||
<li>A</li> | ||
B</li> | ||
<li>C</li> | ||
<ol> | ||
<li>D</li> | ||
<li>E | ||
<p>After</p> | ||
""" | ||
And I click on "HTML" "button" | ||
Then the field "Description" matches multiline: | ||
""" | ||
<p>Before</p> | ||
<ul> | ||
<li>A</li><li> | ||
B</li> | ||
<li>C</li></ul> | ||
<ol> | ||
<li>D</li></ol> | ||
E | ||
<p>After</p> | ||
""" | ||
|
||
@javascript | ||
Scenario: Missing opening LI tags, missing closing UL tag | ||
Given I log in as "admin" | ||
When I open my profile in edit mode | ||
And I click on "Show more buttons" "button" | ||
And I click on "HTML" "button" | ||
And I set the field "Description" to multiline: | ||
""" | ||
<li>Before</li> | ||
<ul> | ||
<li>A</li> | ||
B</li> | ||
<ol> | ||
1</li> | ||
</ol> | ||
<li>C | ||
<li>D</li> | ||
<p>After</p> | ||
""" | ||
And I click on "HTML" "button" | ||
Then the field "Description" matches multiline: | ||
""" | ||
<ul><li>Before</li></ul> | ||
<ul> | ||
<li>A</li><li> | ||
B</li> | ||
<ol><li> | ||
1</li> | ||
</ol> | ||
<li>C | ||
</li><li>D</li></ul> | ||
<p>After</p> | ||
""" |
Oops, something went wrong.