[sonos] Fix remaining org.apache.common (#14450)

Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-02-19 21:51:00 +01:00 committed by GitHub
parent 77f73345d2
commit b570a454b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -25,9 +25,9 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.sonos.internal.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.Attributes;
@ -1084,7 +1084,7 @@ public class SonosXMLParser {
upnpClass = resourceMetaData.getUpnpClass();
}
title = StringEscapeUtils.escapeXml(title);
title = StringUtils.escapeXml(title);
String metadata = METADATA_FORMAT.format(new Object[] { id, parentId, title, upnpClass, desc });

View File

@ -12,13 +12,34 @@
*/
package org.openhab.binding.sonos.internal.util;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link StringUtils} class defines some static string utility methods
*
* @author Leo Siepel - Initial contribution
*/
@NonNullByDefault
public class StringUtils {
/**
* Simple method to escape XML special characters in String.
* There are five XML Special characters which needs to be escaped :
* & - &amp;
* < - &lt;
* > - &gt;
* " - &quot;
* ' - &apos;
*/
public static String escapeXml(String xml) {
xml = xml.replaceAll("&", "&amp;");
xml = xml.replaceAll("<", "&lt;");
xml = xml.replaceAll(">", "&gt;");
xml = xml.replaceAll("\"", "&quot;");
xml = xml.replaceAll("'", "&apos;");
return xml;
}
/**
* Simple method to un escape XML special characters in String.
* There are five XML Special characters which needs to be escaped :