-
-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XWIKI-21803: Unescaped '<' (less than symbol) in in-line style breaks…
… the WYSIWYG editor * Escape '<' in the content of style tags both for the editor HTML input and output, to overcome a bug in CKEditor's HTML parser. * Allow style tags (inside macro output), they were filtered out before by CKEditor's Advanced Content Filter * Add functional test * Rename some functional tests to be consisten. (cherry picked from commit 0f794c9)
- Loading branch information
Showing
6 changed files
with
132 additions
and
9 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
84 changes: 84 additions & 0 deletions
84
.../xwiki-platform-ckeditor-test-docker/src/test/it/org/xwiki/ckeditor/test/ui/FilterIT.java
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,84 @@ | ||
/* | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.xwiki.ckeditor.test.ui; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.xwiki.test.docker.junit5.TestReference; | ||
import org.xwiki.test.docker.junit5.UITest; | ||
import org.xwiki.test.ui.TestUtils; | ||
|
||
/** | ||
* Tests how CKEditor filters the content. | ||
* | ||
* @version $Id$ | ||
*/ | ||
@UITest | ||
class FilterIT extends AbstractCKEditorIT | ||
{ | ||
@BeforeEach | ||
void beforeEach(TestUtils setup, TestReference testReference) | ||
{ | ||
edit(setup, testReference); | ||
} | ||
|
||
@AfterEach | ||
void afterEach(TestUtils setup, TestReference testReference) | ||
{ | ||
maybeLeaveEditMode(setup, testReference); | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
void escapeStyleContent() | ||
{ | ||
StringBuilder source = new StringBuilder(); | ||
source.append("before\n"); | ||
source.append("\n"); | ||
source.append("{{html clean=\"false\"}}\n"); | ||
source.append("<style>\n"); | ||
source.append("p::before {\n"); | ||
source.append(" content: '<';\n"); | ||
source.append("}\n"); | ||
source.append("</style>\n"); | ||
source.append("<div>inside</div>\n"); | ||
source.append("<style id=\"second\">\n"); | ||
source.append("div::after {\n"); | ||
source.append(" content: '<';\n"); | ||
source.append("}\n"); | ||
source.append("</style>\n"); | ||
source.append("{{/html}}\n"); | ||
source.append("\n"); | ||
source.append("after"); | ||
|
||
setSource(source.toString()); | ||
String html = this.textArea.getContent(); | ||
assertTrue(html.contains("<style>"), "Unexpected content: " + html); | ||
assertTrue(html.contains("content: '<'"), "Unexpected content: " + html); | ||
|
||
this.textArea.sendKeys(" end"); | ||
// Verify that the origial style content is preserved. | ||
assertSourceContains(source.toString() + " end"); | ||
} | ||
} |
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