mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-78117 NULL characters appended to file when retrieving historical revisions in SVN
This commit is contained in:
@@ -30,13 +30,13 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.wc.SVNInfo;
|
||||
import org.tmatesoft.svn.core.wc.SVNRevision;
|
||||
import org.tmatesoft.svn.core.wc.SVNWCClient;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -118,19 +118,21 @@ public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevi
|
||||
buffer.close();
|
||||
}
|
||||
catch (SVNException e) {
|
||||
try {
|
||||
/*try {
|
||||
final SVNInfo info = wcClient.doInfo(file, SVNRevision.UNDEFINED);
|
||||
//todo
|
||||
}
|
||||
catch (SVNException e1) {
|
||||
throw new VcsException(e);
|
||||
}
|
||||
}*/
|
||||
throw new VcsException(e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new VcsException(e);
|
||||
}
|
||||
return buffer.toByteArray();
|
||||
final byte[] bytes = buffer.toByteArray();
|
||||
final Charset charset = myFile.getCharset();
|
||||
return charset == null ? bytes : SvnUtil.decode(charset, bytes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.tmatesoft.svn.core.wc2.SvnOperationFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
@@ -683,7 +684,9 @@ public class SvnUtil {
|
||||
|
||||
public static byte[] decode(final Charset charset, final byte[] buffer) {
|
||||
if (charset != null && ! CharsetToolkit.UTF8_CHARSET.equals(charset)) {
|
||||
return CharsetToolkit.UTF8_CHARSET.encode(charset.decode(ByteBuffer.wrap(buffer))).array();
|
||||
final CharBuffer decoded = charset.decode(ByteBuffer.wrap(buffer));
|
||||
final ByteBuffer byteBuffer = CharsetToolkit.UTF8_CHARSET.encode(decoded);
|
||||
return ArrayUtil.realloc(byteBuffer.array(), byteBuffer.remaining());
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user