As discussed, one of the UTs already covers this "whitespace before CDATA case" and the whitespace is ignored. (Note that in your example the CDATA value would be "\n    some text\n  ", though, but that's how CDATA works).

I've reversed the other if block.