mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Repair some common invalid URLs, version bump to 0.6.9. invalid URLs, version bump to 0.6.9.1
This commit is contained in:
parent
ac46b8f45f
commit
0423e00ffd
@ -43,25 +43,29 @@ public class URLUtilsTest extends TestCase {
|
||||
|
||||
public void testParseURI() throws Exception {
|
||||
// don't escape valid characters
|
||||
String validPath = "/;:@&=$-_.+!*'(),";
|
||||
String validPath = "/;:@&=$-_.+!*'(),";
|
||||
assertEquals(new URI("https://www.test.example:123" + validPath), URIUtils.parseURI("https://www.test.example:123" + validPath, false));
|
||||
assertEquals(new URI(validPath), URIUtils.parseURI(validPath, true));
|
||||
|
||||
// keep literal IPv6 addresses (only in host name)
|
||||
assertEquals(new URI("https://[1:2::1]/"), URIUtils.parseURI("https://[1:2::1]/", false));
|
||||
|
||||
// "~" as home directory
|
||||
// "~" as home directory (valid)
|
||||
assertEquals(new URI("http://www.test.example/~user1/"), URIUtils.parseURI("http://www.test.example/~user1/", false));
|
||||
assertEquals(new URI("/~user1/"), URIUtils.parseURI("/%7euser1/", true));
|
||||
|
||||
// "@" in directory name
|
||||
// "@" in path names (valid)
|
||||
assertEquals(new URI("http://www.test.example/user@server.com/"), URIUtils.parseURI("http://www.test.example/user@server.com/", false));
|
||||
assertEquals(new URI("/user@server.com/"), URIUtils.parseURI("/user%40server.com/", true));
|
||||
assertEquals(new URI("user@server.com"), URIUtils.parseURI("user%40server.com", true));
|
||||
|
||||
// ":" in path names
|
||||
// ":" in path names (valid)
|
||||
assertEquals(new URI("http://www.test.example/my:cal.ics"), URIUtils.parseURI("http://www.test.example/my:cal.ics", false));
|
||||
assertEquals(new URI("/my:cal.ics"), URIUtils.parseURI("/my%3Acal.ics", true));
|
||||
assertEquals(new URI(null, null, "my:cal.ics", null, null), URIUtils.parseURI("my%3Acal.ics", true));
|
||||
|
||||
// common invalid path names
|
||||
assertEquals(new URI(null, null, "my cal.ics", null, null), URIUtils.parseURI("my cal.ics", true));
|
||||
assertEquals(new URI(null, null, "{1234}.vcf", null, null), URIUtils.parseURI("{1234}.vcf", true));
|
||||
}
|
||||
}
|
||||
|
@ -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="48"
|
||||
android:versionName="0.6.9" android:installLocation="internalOnly">
|
||||
android:versionCode="49"
|
||||
android:versionName="0.6.9.1" 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",
|
||||
APP_VERSION = "0.6.9.1",
|
||||
ACCOUNT_TYPE = "bitfire.at.davdroid",
|
||||
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app";
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ package at.bitfire.davdroid;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.codec.EncoderException;
|
||||
import org.apache.commons.codec.net.URLCodec;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@ -61,7 +66,16 @@ public class URIUtils {
|
||||
}
|
||||
}
|
||||
|
||||
URI uri = new URI(original);
|
||||
// escape some common invalid characters – servers keep sending unescaped crap like "my calendar.ics" or "{guid}.vcf"
|
||||
// this is only a hack, because for instance, "[" may be valid in URLs (IPv6 literal in host name)
|
||||
String repaired = original
|
||||
.replaceAll(" ", "%20")
|
||||
.replaceAll("\\{", "%7B")
|
||||
.replaceAll("\\}", "%7D");
|
||||
if (!repaired.equals(original))
|
||||
Log.w(TAG, "Repaired invalid URL: " + original + " -> " + repaired);
|
||||
|
||||
URI uri = new URI(repaired);
|
||||
URI normalized = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
|
||||
Log.v(TAG, "Normalized URL " + original + " -> " + normalized.toASCIIString());
|
||||
return normalized;
|
||||
|
Loading…
Reference in New Issue
Block a user