Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 81b99bd3 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #4810 from k9mail/wording

Fix names of some identifiers
parents 87cd4170 8fa8b485
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ public class K9AlarmManager {
    }

    public void set(int type, long triggerAtMillis, PendingIntent operation) {
        if (dozeChecker.isDeviceIdleModeSupported() && dozeChecker.isAppWhitelisted()) {
        if (dozeChecker.isDeviceIdleModeSupported() && dozeChecker.isIgnoringBatteryOptimizations()) {
            setAndAllowWhileIdle(type, triggerAtMillis, operation);
        } else {
            alarmManager.set(type, triggerAtMillis, operation);
+0 −45
Original line number Diff line number Diff line
package com.fsck.k9.message.html;


import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Whitelist;


public class HtmlSanitizer {
    private final HeadCleaner headCleaner;
    private final Cleaner cleaner;

    HtmlSanitizer() {
        Whitelist whitelist = Whitelist.relaxed()
                .addTags("font", "hr", "ins", "del", "center", "map", "area")
                .addAttributes("font", "color", "face", "size")
                .addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
                        "width")
                .addAttributes("tr", "align", "background", "bgcolor", "valign")
                .addAttributes("th",
                        "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
                        "sorted", "valign", "width")
                .addAttributes("td",
                        "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
                        "valign", "width")
                .addAttributes("map", "name")
                .addAttributes("area", "shape", "coords", "href", "alt")
                .addProtocols("area", "href", "http", "https")
                .addAttributes("img", "usemap")
                .addAttributes(":all", "class", "style", "id", "dir")
                .addProtocols("img", "src", "http", "https", "cid", "data")
                .addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp");

        cleaner = new Cleaner(whitelist);
        headCleaner = new HeadCleaner();
    }

    public Document sanitize(String html) {
        Document dirtyDocument = Jsoup.parse(html);
        Document cleanedDocument = cleaner.clean(dirtyDocument);
        headCleaner.clean(dirtyDocument, cleanedDocument);
        return cleanedDocument;
    }
}
+49 −0
Original line number Diff line number Diff line
package com.fsck.k9.message.html

import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.safety.Cleaner
import org.jsoup.safety.Whitelist as AllowList

class HtmlSanitizer {
    private val headCleaner: HeadCleaner
    private val cleaner: Cleaner

    init {
        val allowList = AllowList.relaxed()
            .addTags("font", "hr", "ins", "del", "center", "map", "area")
            .addAttributes("font", "color", "face", "size")
            .addAttributes(
                "table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
                "width"
            )
            .addAttributes("tr", "align", "background", "bgcolor", "valign")
            .addAttributes(
                "th",
                "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
                "sorted", "valign", "width"
            )
            .addAttributes(
                "td",
                "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
                "valign", "width"
            )
            .addAttributes("map", "name")
            .addAttributes("area", "shape", "coords", "href", "alt")
            .addProtocols("area", "href", "http", "https")
            .addAttributes("img", "usemap")
            .addAttributes(":all", "class", "style", "id", "dir")
            .addProtocols("img", "src", "http", "https", "cid", "data")
            .addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp")

        cleaner = Cleaner(allowList)
        headCleaner = HeadCleaner()
    }

    fun sanitize(html: String?): Document {
        val dirtyDocument = Jsoup.parse(html)
        val cleanedDocument = cleaner.clean(dirtyDocument)
        headCleaner.clean(dirtyDocument, cleanedDocument)
        return cleanedDocument
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ public class DozeChecker {
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    public boolean isAppWhitelisted() {
    public boolean isIgnoringBatteryOptimizations() {
        return powerManager.isIgnoringBatteryOptimizations(packageName);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class K9AlarmManagerTest {
    }

    @Test
    public void set_withDozeSupportAndNotWhiteListed_shouldCallSetOnAlarmManager() throws Exception {
    public void set_withDozeSupportAndNotExemptedFromBatteryOptimizations_shouldCallSetOnAlarmManager() throws Exception {
        configureDozeSupport(true);

        alarmManager.set(TIMER_TYPE, TIMEOUT, PENDING_INTENT);
@@ -54,9 +54,9 @@ public class K9AlarmManagerTest {
    }

    @Test
    public void set_withDozeSupportAndWhiteListed_shouldCallSetAndAllowWhileIdleOnAlarmManager() throws Exception {
    public void set_withDozeSupportAndExemptedFromBatteryOptimizations_shouldCallSetAndAllowWhileIdleOnAlarmManager() throws Exception {
        configureDozeSupport(true);
        addAppToBatteryOptimizationWhitelist();
        addAppToIgnoreBatteryOptimizationsList();

        alarmManager.set(TIMER_TYPE, TIMEOUT, PENDING_INTENT);

@@ -66,7 +66,7 @@ public class K9AlarmManagerTest {
    @Test
    public void cancel_shouldCallCancelOnAlarmManager() throws Exception {
        configureDozeSupport(true);
        addAppToBatteryOptimizationWhitelist();
        addAppToIgnoreBatteryOptimizationsList();

        alarmManager.cancel(PENDING_INTENT);

@@ -78,8 +78,8 @@ public class K9AlarmManagerTest {
        when(dozeChecker.isDeviceIdleModeSupported()).thenReturn(supported);
    }

    private void addAppToBatteryOptimizationWhitelist() {
        when(dozeChecker.isAppWhitelisted()).thenReturn(true);
    private void addAppToIgnoreBatteryOptimizationsList() {
        when(dozeChecker.isIgnoringBatteryOptimizations()).thenReturn(true);
    }

    private static PendingIntent createDummyPendingIntent() {
Loading