Prevent HTML Injection on the Device Admin request screen

The root issue is that CharSequence is an interface.
String implements that interface, however, Spanned class
too which is a rich text format that can store HTML code.

The solution is enforce to use String type which won't include
any HTML function.

Test: Rebuilt apk and see the string without HTML style.
Bug: 179042963
Change-Id: I53b460b12da918e022d2f2934f114d205dbaadb0
This commit is contained in:
Tsung-Mao Fang
2021-04-14 15:51:37 +08:00
parent 8d8877b6db
commit 0bf3c98b2f

View File

@@ -108,7 +108,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
DevicePolicyManager mDPM;
AppOpsManager mAppOps;
DeviceAdminInfo mDeviceAdmin;
CharSequence mAddMsgText;
String mAddMsgText;
String mProfileOwnerName;
ImageView mAdminIcon;
@@ -280,7 +280,11 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
}
}
mAddMsgText = getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
final CharSequence addMsgCharSequence = getIntent().getCharSequenceExtra(
DevicePolicyManager.EXTRA_ADD_EXPLANATION);
if (addMsgCharSequence != null) {
mAddMsgText = addMsgCharSequence.toString();
}
if (mAddingProfileOwner) {
// If we're trying to add a profile owner and user setup hasn't completed yet, no
@@ -634,7 +638,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
} catch (Resources.NotFoundException e) {
mAdminDescription.setVisibility(View.GONE);
}
if (mAddMsgText != null) {
if (!TextUtils.isEmpty(mAddMsgText)) {
mAddMsg.setText(mAddMsgText);
mAddMsg.setVisibility(View.VISIBLE);
} else {