File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class PCData(data: String) extends Atom[String](data) {
2626 * @return the input string buffer with the formatted CDATA section
2727 */
2828 override def buildString (sb : StringBuilder ): StringBuilder =
29- sb append " <![CDATA[%s]]>" .format(data)
29+ sb append " <![CDATA[%s]]>" .format(data.replaceAll( " ]]> " , " ]]]]><![CDATA[> " ) )
3030}
3131
3232/**
Original file line number Diff line number Diff line change 1+ package scala .xml
2+
3+ import org .junit .Test
4+ import org .junit .Assert .assertEquals
5+
6+ class PCDataTest {
7+
8+ @ Test
9+ def emptyTest = {
10+ val pcdata = new PCData (" " )
11+ assertEquals(" <![CDATA[]]>" , pcdata.toString)
12+ }
13+
14+ @ Test
15+ def bracketTest = {
16+ val pcdata = new PCData (" []" )
17+ assertEquals(" <![CDATA[[]]]>" , pcdata.toString)
18+ }
19+
20+ @ Test
21+ def hellaBracketingTest = {
22+ val pcdata = new PCData (" [[[[[[[[]]]]]]]]" )
23+ assertEquals(" <![CDATA[[[[[[[[[]]]]]]]]]]>" , pcdata.toString)
24+ }
25+
26+ @ Test
27+ def simpleNestingTest = {
28+ val pcdata = new PCData (" ]]>" )
29+ assertEquals(" <![CDATA[]]]]><![CDATA[>]]>" , pcdata.toString)
30+ }
31+
32+ @ Test
33+ def recursiveNestingTest = {
34+ val pcdata = new PCData (" <![CDATA[]]>" )
35+ assertEquals(" <![CDATA[<![CDATA[]]]]><![CDATA[>]]>" , pcdata.toString)
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments