You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Elliotte Rusty Harold (Jira)" <ji...@apache.org> on 2023/03/16 14:40:00 UTC
[jira] [Updated] (MRELEASE-1117) ReleaseUtil.readXmlFile doesn't respect encoding
[ https://issues.apache.org/jira/browse/MRELEASE-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Elliotte Rusty Harold updated MRELEASE-1117:
--------------------------------------------
Summary: ReleaseUtil.readXmlFile doesn't respect encoding (was: Normalize line endings doesn't respect encoding)
> ReleaseUtil.readXmlFile doesn't respect encoding
> ------------------------------------------------
>
> Key: MRELEASE-1117
> URL: https://issues.apache.org/jira/browse/MRELEASE-1117
> Project: Maven Release Plugin
> Issue Type: Bug
> Reporter: Elliotte Rusty Harold
> Priority: Minor
>
> This chunk of code in ReleaseUtil could be seriously broken in the event of a confusion between single and multibyte encodings. It's not a straight-forward fix and might require some rethinking of the API.
> ```
> public static String readXmlFile(File file, String ls) throws IOException {
> try (Reader reader = ReaderFactory.newXmlReader(file)) {
> return normalizeLineEndings(IOUtil.toString(reader), ls);
> }
> }
> /**
> * Normalizes the line separators in the specified string.
> *
> * @param text The string to normalize, may be <code>null</code>.
> * @param separator The line separator to use for normalization, typically "\n" or "\r\n", must not be
> * <code>null</code>.
> * @return The input string with normalized line separators or <code>null</code> if the string was <code>null</code>
> * .
> */
> public static String normalizeLineEndings(String text, String separator) {
> String norm = text;
> if (text != null) {
> norm = text.replaceAll("(\r\n)|(\n)|(\r)", separator);
> }
> return norm;
> }
> ```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)