From 5df5d1d7b5479eb25720283ad6cd0e8161933e9b Mon Sep 17 00:00:00 2001 From: Bartosz Przybylski Date: Tue, 6 Feb 2018 17:11:33 +0100 Subject: [PATCH 1/2] Don't beautify empty inputs --- .../java/com/owncloud/android/utils/DisplayUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/src/main/java/com/owncloud/android/utils/DisplayUtils.java index b6034ce6e9..7c34a6a4c6 100644 --- a/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -38,11 +38,13 @@ import android.graphics.drawable.PictureDrawable; import android.net.Uri; import android.os.Build; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.design.widget.BottomNavigationView; import android.support.design.widget.Snackbar; import android.text.Spannable; import android.text.SpannableStringBuilder; +import android.text.TextUtils; import android.text.format.DateUtils; import android.text.style.StyleSpan; import android.view.Menu; @@ -188,8 +190,8 @@ public class DisplayUtils { * @param url to be beautified url * @return beautified url */ - public static String beautifyURL(String url) { - if (url == null) { + public static String beautifyURL(@Nullable String url) { + if (TextUtils.isEmpty(url)) { return ""; } @@ -210,8 +212,8 @@ public class DisplayUtils { * @param handle to be beautified twitter handle * @return beautified twitter handle */ - public static String beautifyTwitterHandle(String handle) { - if (handle == null) { + public static String beautifyTwitterHandle(@Nullable String handle) { + if (TextUtils.isEmpty(handle)) { return ""; } From b1f5ae5297145c872514eb9c0c9a811b30f0f181 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Mon, 12 Feb 2018 18:10:12 +0100 Subject: [PATCH 2/2] also trim() when beatifying URLs and twitter handles --- .../java/com/owncloud/android/utils/DisplayUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 7c34a6a4c6..d6962972b5 100644 --- a/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -196,14 +196,14 @@ public class DisplayUtils { } if (url.length() >= 7 && url.substring(0, 7).equalsIgnoreCase(HTTP_PROTOCOLL)) { - return url.substring(HTTP_PROTOCOLL.length()); + return url.substring(HTTP_PROTOCOLL.length()).trim(); } if (url.length() >= 8 && url.substring(0, 8).equalsIgnoreCase(HTTPS_PROTOCOLL)) { - return url.substring(HTTPS_PROTOCOLL.length()); + return url.substring(HTTPS_PROTOCOLL.length()).trim(); } - return url; + return url.trim(); } /** @@ -218,9 +218,9 @@ public class DisplayUtils { } if (handle.startsWith(TWITTER_HANDLE_PREFIX)) { - return handle; + return handle.trim(); } else { - return TWITTER_HANDLE_PREFIX + handle; + return TWITTER_HANDLE_PREFIX + handle.trim(); } }