[ https://issues.apache.org/jira/browse/MRELEASE-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701097#comment-17701097 ]
Michael Osipov edited comment on MRELEASE-1117 at 3/16/23 11:20 AM: -------------------------------------------------------------------- Why? It operates on strings (chars), not bytes. was (Author: michael-o): Why? It operated on strings (chars), not bytes. > 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 > 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)