Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Jan 9, 2020
2 parents 79bbbea + 2270e8c commit c3b6d9c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>fuse-nio-adapter</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<name>FUSE-NIO-Adapter</name>
<description>Access resources at a given NIO path via FUSE.</description>
<url>https://github.com/cryptomator/fuse-nio-adapter</url>
Expand Down Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>cryptofs</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
Expand All @@ -32,6 +34,7 @@ class MacMounter implements Mounter {
private static final int[] OSXFUSE_MINIMUM_SUPPORTED_VERSION = new int[]{3, 8, 2};
private static final String OSXFUSE_VERSIONFILE_LOCATION = "/Library/Filesystems/osxfuse.fs/Contents/version.plist";
private static final String OSXFUSE_VERSIONFILE_XPATH = "/plist/dict/key[.='CFBundleShortVersionString']/following-sibling::string[1]";
private static final String PLIST_DTD_URL = "http://www.apple.com/DTDs/PropertyList-1.0.dtd";

@Override
public synchronized Mount mount(Path directory, EnvironmentVariables envVars) throws CommandFailedException {
Expand Down Expand Up @@ -103,7 +106,9 @@ private String getVersionString() {
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
XPath xPath = XPathFactory.newInstance().newXPath();
try (InputStream in = Files.newInputStream(plistFile, StandardOpenOption.READ)) {
Document doc = domFactory.newDocumentBuilder().parse(in);
DocumentBuilder docBuilder = domFactory.newDocumentBuilder();
docBuilder.setEntityResolver(this::resolveEntity);
Document doc = docBuilder.parse(in);
NodeList nodeList = (NodeList) xPath.compile(OSXFUSE_VERSIONFILE_XPATH).evaluate(doc, XPathConstants.NODESET);
Node node = nodeList.item(0);
if (node == null) {
Expand All @@ -120,6 +125,15 @@ private String getVersionString() {
}
}

private InputSource resolveEntity(String publicId, String systemId) {
if (PLIST_DTD_URL.equals(systemId)) {
// load DTD from local resource. fixes https://github.com/cryptomator/fuse-nio-adapter/issues/40
return new InputSource(getClass().getResourceAsStream("/PropertyList-1.0.dtd"));
} else {
return null;
}
}

private static class MacMount extends AbstractMount {

private final ProcessBuilder revealCommand;
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/PropertyList-1.0.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!ENTITY % plistObject "(array | data | date | dict | real | integer | string | true | false )" >
<!ELEMENT plist %plistObject;>
<!ATTLIST plist version CDATA "1.0" >

<!-- Collections -->
<!ELEMENT array (%plistObject;)*>
<!ELEMENT dict (key, %plistObject;)*>
<!ELEMENT key (#PCDATA)>

<!--- Primitive types -->
<!ELEMENT string (#PCDATA)>
<!ELEMENT data (#PCDATA)> <!-- Contents interpreted as Base-64 encoded -->
<!ELEMENT date (#PCDATA)> <!-- Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. Smaller units may be omitted with a loss of precision) -->

<!-- Numerical primitives -->
<!ELEMENT true EMPTY> <!-- Boolean constant true -->
<!ELEMENT false EMPTY> <!-- Boolean constant false -->
<!ELEMENT real (#PCDATA)> <!-- Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | "-") d+)? where d is a digit 0-9. -->
<!ELEMENT integer (#PCDATA)> <!-- Contents should represent a (possibly signed) integer number in base 10 -->

0 comments on commit c3b6d9c

Please sign in to comment.