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

Commit 34660c5e authored by William Loh's avatar William Loh Committed by Android (Google) Code Review
Browse files

Merge "Restrict mimeGroup name length to 1024" into main

parents 477a62f6 a9c83f96
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,8 @@ import androidx.annotation.StyleableRes;


import com.android.internal.R;
import com.android.internal.R;


import java.util.Set;

/**
/**
 * Defines the string attribute length and child tag count restrictions for a xml element.
 * Defines the string attribute length and child tag count restrictions for a xml element.
 *
 *
@@ -37,7 +39,11 @@ public class Element {
    private static final int MAX_ATTR_LEN_URL_COMPONENT = 256;
    private static final int MAX_ATTR_LEN_URL_COMPONENT = 256;
    private static final int MAX_ATTR_LEN_PERMISSION_GROUP = 256;
    private static final int MAX_ATTR_LEN_PERMISSION_GROUP = 256;
    private static final int MAX_ATTR_LEN_PACKAGE = 256;
    private static final int MAX_ATTR_LEN_PACKAGE = 256;
    private static final int MAX_ATTR_LEN_MIMETYPE = 512;
    /**
     * The mime type max length restriction here should match the restriction that is also
     * placed in {@link android.content.pm.PackageManager#setMimeGroup(String, Set)}
     */
    private static final int MAX_ATTR_LEN_MIMETYPE = 255;
    private static final int MAX_ATTR_LEN_NAME = 1024;
    private static final int MAX_ATTR_LEN_NAME = 1024;
    private static final int MAX_ATTR_LEN_PATH = 4000;
    private static final int MAX_ATTR_LEN_PATH = 4000;
    private static final int MAX_ATTR_LEN_VALUE = 32_768;
    private static final int MAX_ATTR_LEN_VALUE = 32_768;
@@ -103,6 +109,7 @@ public class Element {
    protected static final String TAG_ATTR_HOST = "host";
    protected static final String TAG_ATTR_HOST = "host";
    protected static final String TAG_ATTR_MANAGE_SPACE_ACTIVITY = "manageSpaceActivity";
    protected static final String TAG_ATTR_MANAGE_SPACE_ACTIVITY = "manageSpaceActivity";
    protected static final String TAG_ATTR_MIMETYPE = "mimeType";
    protected static final String TAG_ATTR_MIMETYPE = "mimeType";
    protected static final String TAG_ATTR_MIMEGROUP = "mimeGroup";
    protected static final String TAG_ATTR_NAME = "name";
    protected static final String TAG_ATTR_NAME = "name";
    protected static final String TAG_ATTR_PACKAGE = "package";
    protected static final String TAG_ATTR_PACKAGE = "package";
    protected static final String TAG_ATTR_PATH = "path";
    protected static final String TAG_ATTR_PATH = "path";
@@ -367,6 +374,7 @@ public class Element {
            case TAG_ATTR_BACKUP_AGENT:
            case TAG_ATTR_BACKUP_AGENT:
            case TAG_ATTR_CATEGORY:
            case TAG_ATTR_CATEGORY:
            case TAG_ATTR_MANAGE_SPACE_ACTIVITY:
            case TAG_ATTR_MANAGE_SPACE_ACTIVITY:
            case TAG_ATTR_MIMEGROUP:
            case TAG_ATTR_NAME:
            case TAG_ATTR_NAME:
            case TAG_ATTR_PARENT_ACTIVITY_NAME:
            case TAG_ATTR_PARENT_ACTIVITY_NAME:
            case TAG_ATTR_PERMISSION:
            case TAG_ATTR_PERMISSION:
@@ -520,6 +528,8 @@ public class Element {
                return MAX_ATTR_LEN_URL_COMPONENT;
                return MAX_ATTR_LEN_URL_COMPONENT;
            case R.styleable.AndroidManifestData_mimeType:
            case R.styleable.AndroidManifestData_mimeType:
                return MAX_ATTR_LEN_MIMETYPE;
                return MAX_ATTR_LEN_MIMETYPE;
            case R.styleable.AndroidManifestData_mimeGroup:
                return MAX_ATTR_LEN_NAME;
            case R.styleable.AndroidManifestData_path:
            case R.styleable.AndroidManifestData_path:
            case R.styleable.AndroidManifestData_pathPattern:
            case R.styleable.AndroidManifestData_pathPattern:
            case R.styleable.AndroidManifestData_pathPrefix:
            case R.styleable.AndroidManifestData_pathPrefix:
+3 −2
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ class AndroidPackageParsingValidationTest {
        validateTagCount("uses-library", 1000, tag)
        validateTagCount("uses-library", 1000, tag)
        validateTagCount("activity-alias", 4000, tag)
        validateTagCount("activity-alias", 4000, tag)
        validateTagCount("provider", 8000, tag)
        validateTagCount("provider", 8000, tag)
        validateTagCount("activity", 40000, tag)
        validateTagCount("activity", 30000, tag)
    }
    }


    @Test
    @Test
@@ -465,7 +465,8 @@ class AndroidPackageParsingValidationTest {
            R.styleable.AndroidManifestData_pathAdvancedPattern,
            R.styleable.AndroidManifestData_pathAdvancedPattern,
            4000
            4000
        )
        )
        validateTagAttr(tag, "mimeType", R.styleable.AndroidManifestData_mimeType, 512)
        validateTagAttr(tag, "mimeType", R.styleable.AndroidManifestData_mimeType, 255)
        validateTagAttr(tag, "mimeGroup", R.styleable.AndroidManifestData_mimeGroup, 1024)
    }
    }


    @Test
    @Test