mirror of
https://github.com/etesync/android
synced 2024-11-22 07:58:09 +00:00
Handle resources with "%" and other special characters in file name more accurately (fixes #401)
This commit is contained in:
parent
0423e00ffd
commit
6f5748c464
@ -13,7 +13,7 @@ Twitter: [@davdroidapp](https://twitter.com/davdroidapp)
|
||||
USED THIRD-PARTY LIBRARIES
|
||||
==========================
|
||||
|
||||
* [Apache HttpClient](http://hc.apache.org) ([httpclientandroidlib](https://code.google.com/p/httpclientandroidlib/) flavour) – [Apache License](http://www.apache.org/licenses/)
|
||||
* [Apache HttpClient](http://hc.apache.org) (Android port) – [Apache License](http://www.apache.org/licenses/)
|
||||
* [iCal4j](http://ical4j.sourceforge.net/) – [New BSD License](http://sourceforge.net/p/ical4j/ical4j/ci/default/tree/LICENSE)
|
||||
* [ez-vcard](https://code.google.com/p/ez-vcard/) – [New BSD License](http://opensource.org/licenses/BSD-3-Clause)
|
||||
* [Simple XML Serialization](http://simple.sourceforge.net/) – [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
@ -12,6 +12,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
minifyEnabled false
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
|
@ -170,10 +170,16 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testMultiGet() throws Exception {
|
||||
WebDavResource davAddressBook = new WebDavResource(davCollection, "addressbooks/default.vcf");
|
||||
davAddressBook.multiGet(DavMultiget.Type.ADDRESS_BOOK, new String[] { "1.vcf", "2.vcf" });
|
||||
WebDavResource davAddressBook = new WebDavResource(davCollection, "addressbooks/default.vcf/");
|
||||
davAddressBook.multiGet(DavMultiget.Type.ADDRESS_BOOK, new String[] { "1.vcf", "2:3@my%40pc.vcf" });
|
||||
// queried address book has a name
|
||||
assertEquals("My Book", davAddressBook.getDisplayName());
|
||||
// there are two contacts
|
||||
assertEquals(2, davAddressBook.getMembers().size());
|
||||
// contact file names should be unescaped (yes, it's really named ...%40pc... to check double-encoding)
|
||||
assertEquals("1.vcf", davAddressBook.getMembers().get(0).getName());
|
||||
assertEquals("2:3@my%40pc.vcf", davAddressBook.getMembers().get(1).getName());
|
||||
// both contacts have content
|
||||
for (WebDavResource member : davAddressBook.getMembers())
|
||||
assertNotNull(member.getContent());
|
||||
}
|
||||
|
@ -224,14 +224,16 @@ exports.getBodyParts = function(conf) {
|
||||
new RoboHydraHeadDAV({
|
||||
path: "/dav/addressbooks/default.vcf/",
|
||||
handler: function(req,res,next) {
|
||||
if (req.method == "REPORT" && req.rawBody.toString().match(/addressbook-multiget[\s\S]+<prop>[\s\S]+<href>/m)) {
|
||||
if (req.method == "REPORT" && req.rawBody.toString().match(/addressbook-multiget[\s\S]+<prop>[\s\S]+<href>/m &&
|
||||
req.rawBody.toString().match(/<href>\/dav\/addressbooks\/default\.vcf\/2:3@my%2540pc\.vcf<\/href>/m))) {
|
||||
res.statusCode = 207;
|
||||
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
|
||||
<multistatus xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
|
||||
<response>\
|
||||
<href>/dav/addressbooks/d%65fault.vcf</href>\
|
||||
<href>/dav/addressbooks/default.vcf</href>\
|
||||
<propstat>\
|
||||
<prop>\
|
||||
<resourcetype><collection/></resourcetype>\
|
||||
<displayname>My Book</displayname>\
|
||||
</prop>\
|
||||
<status>HTTP/1.1 200 OK</status>\
|
||||
@ -253,7 +255,7 @@ exports.getBodyParts = function(conf) {
|
||||
</propstat>\
|
||||
</response>\
|
||||
<response>\
|
||||
<href>/dav/addressbooks/default.vcf/2.vcf</href>\
|
||||
<href>/dav/addressbooks/default.vcf/2:3%40my%2540pc.vcf</href>\
|
||||
<propstat>\
|
||||
<prop>\
|
||||
<getetag/>\
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="at.bitfire.davdroid"
|
||||
android:versionCode="49"
|
||||
android:versionName="0.6.9.1" android:installLocation="internalOnly">
|
||||
android:versionCode="50"
|
||||
android:versionName="0.6.9.2" android:installLocation="internalOnly">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -9,7 +9,7 @@ package at.bitfire.davdroid;
|
||||
|
||||
public class Constants {
|
||||
public static final String
|
||||
APP_VERSION = "0.6.9.1",
|
||||
APP_VERSION = "0.6.9.2",
|
||||
ACCOUNT_TYPE = "bitfire.at.davdroid",
|
||||
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app";
|
||||
}
|
||||
|
@ -296,7 +296,10 @@ public class WebDavResource {
|
||||
// build multi-get XML request
|
||||
List<String> hrefs = new LinkedList<String>();
|
||||
for (String name : names)
|
||||
hrefs.add(location.resolve(name).getPath());
|
||||
// name may contain "%" which have to be encoded → use non-quoting URI constructor and getRawPath()
|
||||
// name may also contain ":", so prepend "./" because even the non-quoting URI constructor parses after constructing
|
||||
// DAVdroid ensures that collections always have a trailing slash, so "./" won't go down in directory hierarchy
|
||||
hrefs.add(location.resolve(new URI(null, null, "./" + name, null)).getRawPath());
|
||||
DavMultiget multiget = DavMultiget.newRequest(type, hrefs.toArray(new String[0]));
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
|
Loading…
Reference in New Issue
Block a user