Merge "Fix possible security issue. Bug #2553187" into froyo

This commit is contained in:
Romain Guy
2010-03-29 16:31:14 -07:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 5 deletions

View File

@@ -78,9 +78,11 @@ public class PackageItemInfo {
public PackageItemInfo(PackageItemInfo orig) { public PackageItemInfo(PackageItemInfo orig) {
name = orig.name; name = orig.name;
if (name != null) name = name.trim();
packageName = orig.packageName; packageName = orig.packageName;
labelRes = orig.labelRes; labelRes = orig.labelRes;
nonLocalizedLabel = orig.nonLocalizedLabel; nonLocalizedLabel = orig.nonLocalizedLabel;
if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
icon = orig.icon; icon = orig.icon;
metaData = orig.metaData; metaData = orig.metaData;
} }
@@ -103,10 +105,10 @@ public class PackageItemInfo {
if (labelRes != 0) { if (labelRes != 0) {
CharSequence label = pm.getText(packageName, labelRes, null); CharSequence label = pm.getText(packageName, labelRes, null);
if (label != null) { if (label != null) {
return label; return label.toString().trim();
} }
} }
if(name != null) { if (name != null) {
return name; return name;
} }
return packageName; return packageName;

View File

@@ -133,7 +133,7 @@ public class ResolveInfo implements Parcelable {
if (resolvePackageName != null && labelRes != 0) { if (resolvePackageName != null && labelRes != 0) {
label = pm.getText(resolvePackageName, labelRes, null); label = pm.getText(resolvePackageName, labelRes, null);
if (label != null) { if (label != null) {
return label; return label.toString().trim();
} }
} }
ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo;
@@ -141,10 +141,14 @@ public class ResolveInfo implements Parcelable {
if (labelRes != 0) { if (labelRes != 0) {
label = pm.getText(ci.packageName, labelRes, ai); label = pm.getText(ci.packageName, labelRes, ai);
if (label != null) { if (label != null) {
return label; return label.toString().trim();
} }
} }
return ci.loadLabel(pm);
CharSequence data = ci.loadLabel(pm);
// Make the data safe
if (data != null) data = data.toString().trim();
return data;
} }
/** /**

View File

@@ -42,12 +42,14 @@
android:textAppearance="?android:attr/textAppearanceLargeInverse" android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="2"
android:paddingLeft="10dip" /> android:paddingLeft="10dip" />
<!-- Extended activity info to distinguish between duplicate activity names --> <!-- Extended activity info to distinguish between duplicate activity names -->
<TextView android:id="@android:id/text2" <TextView android:id="@android:id/text2"
android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="2"
android:paddingLeft="10dip" /> android:paddingLeft="10dip" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>