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 11:06:00 UTC
[jira] [Created] (MRELEASE-1117) Normalize line endings doesn't respect encoding
Elliotte Rusty Harold created MRELEASE-1117:
-----------------------------------------------
Summary: Normalize line endings 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
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)