SPARK-1513: CDATA end sequence would break transcript xml

<![CDATA]]> end sequence would break the transcript log xml. Since every
char gets run through the escapeForXML() method, it was necessary to
check for the ending sequence after the entire string has been escaped.