From c72ece80ee2a34c1cdc74381479b8707120622bb Mon Sep 17 00:00:00 2001 From: "eugene.nizienko" Date: Fri, 26 Jan 2024 18:30:40 +0100 Subject: [PATCH] fixed issue with bad char in html node --- .../remoterobot/services/xpath/XpathDataModelCreator.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/robot-server-core/src/main/kotlin/com/intellij/remoterobot/services/xpath/XpathDataModelCreator.kt b/robot-server-core/src/main/kotlin/com/intellij/remoterobot/services/xpath/XpathDataModelCreator.kt index f16ca65a..9484a448 100644 --- a/robot-server-core/src/main/kotlin/com/intellij/remoterobot/services/xpath/XpathDataModelCreator.kt +++ b/robot-server-core/src/main/kotlin/com/intellij/remoterobot/services/xpath/XpathDataModelCreator.kt @@ -108,7 +108,7 @@ class XpathDataModelCreator(private val textToKeyCache: TextToKeyCache) { }?.apply { element.setAttribute(attributeName, this) } - value?.apply { + value?.removeInvalidXmlCharacters()?.apply { if (textFieldsFilter(attributeName, value)) { elementText.append("$attributeName: '$this'. ") textToKeyCache.findKey(value)?.apply { @@ -308,3 +308,7 @@ fun Element.addIcon(iconName: String, size: Int, onClickFunction: String) { ) appendChild(icon) } + +private fun String.removeInvalidXmlCharacters(): String { + return replace(Regex("[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]"), "") +} \ No newline at end of file