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

Commit db96149e authored by William Loh's avatar William Loh Committed by Automerger Merge Worker
Browse files

Limit length and number of MIME types you can set am: 3ae3406b am:...

Limit length and number of MIME types you can set am: 3ae3406b am: d47de97f am: bcd7713f am: bcca2354

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19785208



Change-Id: I720c3bd7ab64488ead932c723067aba04cb5007b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e7253363 bcca2354
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1695,6 +1695,9 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        for (int i = component.getIntents().size() - 1; i >= 0; i--) {
            IntentFilter filter = component.getIntents().get(i);
            for (int groupIndex = filter.countMimeGroups() - 1; groupIndex >= 0; groupIndex--) {
                if (mimeGroups != null && mimeGroups.size() > 500) {
                    throw new IllegalStateException("Max limit on number of MIME Groups reached");
                }
                mimeGroups = ArrayUtils.add(mimeGroups, filter.getMimeGroup(groupIndex));
            }
        }
+9 −0
Original line number Diff line number Diff line
@@ -328,11 +328,20 @@ public class PackageSetting extends PackageSettingBase {
    }

    public boolean setMimeGroup(String mimeGroup, List<String> mimeTypes) {
        for (String mimeType : mimeTypes) {
            if (mimeType.length() > 255) {
                throw new IllegalArgumentException("MIME type length exceeds 255 characters");
            }
        }
        ArraySet<String> oldMimeTypes = getMimeGroupInternal(mimeGroup);
        if (oldMimeTypes == null) {
            throw new IllegalArgumentException("Unknown MIME group " + mimeGroup
                    + " for package " + name);
        }
        if (mimeTypes.size() > 500) {
            throw new IllegalStateException("Max limit on MIME types for MIME group "
                    + mimeGroup + " exceeded for package " + name);
        }

        ArraySet<String> newMimeTypes = new ArraySet<>(mimeTypes);
        boolean hasChanges = !newMimeTypes.equals(oldMimeTypes);