diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d8a60087..5f2846dd 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="25" + android:versionName="0.4.2" > nameValuePairs, final String username, final String password, Context context) throws AuthenticationException, Exception { if(nameValuePairs != null) urlString += "&" + URLEncodedUtils.format(nameValuePairs, "utf-8"); - URL url = new URL(urlString); + URL url = new URL(API.validateURL(urlString)); HttpURLConnection urlConnection = getUrlConnection(url, context, username, password); //HttpsURLConnection urlConnection = null; @@ -69,6 +71,12 @@ public class HttpJsonRequest { urlConnection.setReadTimeout(120000);//2min urlConnection.setRequestProperty("Content-Type","application/json"); + + //if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) + // CookieHandler.setDefault(new CookieManager()); + + + //urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)"); //urlConnection.setRequestProperty("Host", "de.luhmer.ownCloudNewsReader"); urlConnection.connect(); @@ -117,7 +125,7 @@ public class HttpJsonRequest { @SuppressLint("DefaultLocale") public static int performTagChangeRequest(String urlString, String username, String password, Context context, String content) throws Exception { - URL url = new URL(urlString); + URL url = new URL(API.validateURL(urlString)); HttpURLConnection urlConnection = getUrlConnection(url, context, username, password); urlConnection.setDoOutput(true); urlConnection.setRequestMethod("PUT"); diff --git a/src/de/luhmer/owncloudnewsreader/reader/owncloud/API.java b/src/de/luhmer/owncloudnewsreader/reader/owncloud/API.java index ca019c97..2029d8b9 100644 --- a/src/de/luhmer/owncloudnewsreader/reader/owncloud/API.java +++ b/src/de/luhmer/owncloudnewsreader/reader/owncloud/API.java @@ -15,7 +15,7 @@ import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2; public abstract class API { protected SharedPreferences mPrefs; - Pattern RemoveAllDoubleSlashes = Pattern.compile("[^:](\\/\\/)"); + static final Pattern RemoveAllDoubleSlashes = Pattern.compile("[^:](\\/\\/)"); public API(Context cont) { mPrefs = PreferenceManager.getDefaultSharedPreferences(cont); @@ -46,14 +46,16 @@ public abstract class API { /** * - * @return http(s)://url_to_server/ + * @return http(s)://url_to_server */ protected String getOcRootPath() { String oc_root_path = mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, ""); oc_root_path = RemoveAllDoubleSlashes.matcher(oc_root_path).replaceAll("/"); - if(!oc_root_path.endsWith("/")) - oc_root_path += "/"; + //if(!oc_root_path.endsWith("/")) + // oc_root_path += "/"; + //while(oc_root_path.endsWith("/")) + // oc_root_path += oc_root_path.substring(0, oc_root_path.length() - 2); return oc_root_path; } @@ -83,5 +85,9 @@ public abstract class API { return OwnCloudReaderMethods.GetUpdatedItems(tag, cont, lastSync, api); } + public static String validateURL(String url) { + return RemoveAllDoubleSlashes.matcher(url).replaceAll("/"); + } + public abstract boolean PerformTagExecution(List itemIds, FeedItemTags.TAGS tag, Context context, API api); } \ No newline at end of file