From ac114b2ca41be93b9c3abe1a6da6f71b51e333f1 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Thu, 19 Sep 2024 17:50:49 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20Always=20make=20sure=20we=20pu?= =?UTF-8?q?t=20valid=20utf8-encoded=20strings=20into=20attribut=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 11514611f71e1b41c002ca118aba49e68be47acc. --- .../io/appium/uiautomator2/utils/XMLHelpers.java | 14 +------------- .../appium/uiautomator2/utils/XMLHelpersTests.java | 8 -------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/app/src/main/java/io/appium/uiautomator2/utils/XMLHelpers.java b/app/src/main/java/io/appium/uiautomator2/utils/XMLHelpers.java index dd08eec24..8810d871d 100644 --- a/app/src/main/java/io/appium/uiautomator2/utils/XMLHelpers.java +++ b/app/src/main/java/io/appium/uiautomator2/utils/XMLHelpers.java @@ -18,7 +18,6 @@ import androidx.annotation.Nullable; -import java.nio.charset.StandardCharsets; import java.util.regex.Pattern; public abstract class XMLHelpers { @@ -51,18 +50,7 @@ public static String toNodeName(String str) { @Nullable public static String toSafeString(@Nullable Object source, String replacement) { return source == null ? null : XML10_PATTERN - .matcher(toSafeUtf8String(String.valueOf(source))) + .matcher(String.valueOf(source)) .replaceAll(replacement); } - - @Nullable - public static String toSafeUtf8String(@Nullable String source) { - if (source == null) { - return null; - } - - // This method always replaces malformed-input and unmappable-character sequences - // with this charset's default replacement byte array. - return new String(source.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - } } diff --git a/app/src/test/java/io/appium/uiautomator2/utils/XMLHelpersTests.java b/app/src/test/java/io/appium/uiautomator2/utils/XMLHelpersTests.java index 7815528f7..b7d6271e1 100644 --- a/app/src/test/java/io/appium/uiautomator2/utils/XMLHelpersTests.java +++ b/app/src/test/java/io/appium/uiautomator2/utils/XMLHelpersTests.java @@ -34,8 +34,6 @@ import static org.junit.Assert.assertEquals; -import static io.appium.uiautomator2.utils.XMLHelpers.toSafeString; - import android.os.SystemClock; import java.io.ByteArrayInputStream; @@ -240,12 +238,6 @@ private static List findNodesUsingXpath1(String xml, String xpathSelect } } - @Test - public void createsSafeXmlString() { - String text = toSafeString("°C\u000b", "?"); - assertEquals(text, "°C?"); - } - @Test public void parsesComplexXpath1() { String query = "(//android.widget.TextView[@text='some, text']/following::android.widget.ImageButton)[1]";