From be48eaf9ed01ca68f1ea48732c1ebcbdb091162a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 27 Apr 2014 07:29:23 +0000 Subject: [PATCH] * make sure to avoid unicode decomposition issues --- source/net/filebot/MetaAttributeView.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/MetaAttributeView.java b/source/net/filebot/MetaAttributeView.java index 8a207dca..9d69f64d 100644 --- a/source/net/filebot/MetaAttributeView.java +++ b/source/net/filebot/MetaAttributeView.java @@ -9,6 +9,8 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.UserDefinedFileAttributeView; +import java.text.Normalizer; +import java.text.Normalizer.Form; import java.util.AbstractMap; import java.util.Arrays; import java.util.LinkedHashSet; @@ -50,18 +52,24 @@ public class MetaAttributeView extends AbstractMap { // try 3rd party Xattrj library if (xattr == null) { if (Platform.isMac()) { + // Xattrj for Mac try { xattr = getMacXattrSupport(); } catch (Throwable e) { throw new IOException("Unable to load library: xattrj", e); } + + // MacOS filesystem may require NFD unicode decomposition + this.file = new File(Normalizer.normalize(path.toFile().getAbsolutePath(), Form.NFD)); + this.encoding = Charset.forName("UTF-8"); } else { throw new IOException("UserDefinedFileAttributeView is not supported"); } + } else { + // UserDefinedFileAttributeView + this.file = path.toFile(); + this.encoding = Charset.forName("UTF-8"); } - - this.file = path.toFile(); - this.encoding = Charset.forName("UTF-8"); } @Override