From 0430d0b06045d02cfd2b38796d3eaeb6052597f4 Mon Sep 17 00:00:00 2001 From: Hosam Aly Date: Thu, 5 Apr 2018 20:10:06 +0100 Subject: [PATCH] Discard control characters in Utility.escape I encountered some input that happened to contain some control characters. This PR removes them from the output. The previous behaviour used to exclude control characters in the smaller range. This PR excludes the ones between 0x7F (ASCII 127) and 0x9F (159), plus possible future updates that Java supports. --- shared/src/main/scala/scala/xml/Utility.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/scala/scala/xml/Utility.scala b/shared/src/main/scala/scala/xml/Utility.scala index f7290ed1b..cf18a01c9 100755 --- a/shared/src/main/scala/scala/xml/Utility.scala +++ b/shared/src/main/scala/scala/xml/Utility.scala @@ -113,7 +113,7 @@ object Utility extends AnyRef with parsing.TokenTests { text.iterator.foldLeft(s) { (s, c) => escMap.get(c) match { case Some(str) => s ++= str - case _ if c >= ' ' || "\n\r\t".contains(c) => s += c + case _ if !c.isControl || "\n\r\t".contains(c) => s += c case _ => s // noop } }