k0shk0sh / FastHub

FastHub the ultimate GitHub client for Android.
GNU General Public License v3.0
5.71k stars 931 forks source link

fix: add logic for replace html escaped symbols in uri string. #2899

Open Kiolk opened 4 years ago

Kiolk commented 4 years ago

Hi folks. I investigated the problem with issue https://github.com/k0shk0sh/FastHub/issues/2890 The problem happens when extract URL from Html node, where & present as &amp (by 'net.sourceforge.htmlcleaner:htmlcleaner:2.2'). It normal display in TextView. Uri.parse() not converted this escaped symbol and try open page with it. I not sure, this solution is best, but it resolves the problem.

chuyenvanduong2002 commented 4 years ago

how about oppo a91

Kiolk commented 4 years ago

how about oppo a91

I don't clear understand you. Can you explain you comment more details?

KaustubhPatange commented 3 years ago

Looks like a code smell to me! I would suggest editing LinkParseHelper file to include a static hashmap of all escape symbol & a helper function to remove them all.

A pseudo-code is given below.

public class LinkParserHelper {
    ...
    static final Map<String, String> escapeSymbols = ...

    public static String removeEscapeSymbols(String url) {
        for(Map.Entry<String, String> value : escapeSymbols.entrySet()) {
            url = url.replace(value.getKey(), value.getValue());
        }
        return url;
    }
}

The only problem is the LinkParseHelper class in written in java so the code must be in java. Anyway, you can then call the static function at the appropriate call site.

cypher01-droid commented 3 years ago

looks like a code to me

On Thu, Nov 12, 2020, 13:06 Kaustubh Patange notifications@github.com wrote:

Looks like a code smell to me! I would suggest editing LinkParseHelper https://github.com/k0shk0sh/FastHub/blob/development/app/src/main/java/com/fastaccess/provider/scheme/LinkParserHelper.java file to include a static hashmap of all escape symbol & a helper function to remove them all.

A pseudo-code is given below.

public class LinkParserHelper { ... static final Map<String, String> escapeSymbols = ...

public static String removeEscapeSymbols(String url) {
    for(Map.Entry<String, String> value : escapeSymbols.entrySet()) {
        url = url.replace(value.getKey(), value.getValue());
    }
    return url;
}

}

The only problem is the LinkParseHelper class in written in java so the code must be in java. Anyway, you can then call the static function at the appropriate call site.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/k0shk0sh/FastHub/pull/2899#issuecomment-726037569, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ3EC5ZDNLYMJYGXIIIEPGTSPPFVBANCNFSM4ML6ZOJQ .