Skip to content

Commit 89ea4ca

Browse files
James DongAndroid (Google) Code Review
authored andcommitted
Merge "make sure that lower-case mime and file suffix is used to check against the supported ones"
2 parents 8e3fac2 + 29cdbc8 commit 89ea4ca

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ android::status_t FwdLockEngine::onTerminate(int uniqueId) {
159159
return DRM_NO_ERROR;
160160
}
161161

162+
// make sure that lower-case letters are used.
162163
const String8 FwdLockEngine::FileSuffixes[] = {
163164
String8(".fl"),
164165
String8(".dm"),
165166
};
166167

168+
// make sure that lower-case letters are used.
167169
const String8 FwdLockEngine::MimeTypes[] = {
168170
String8("application/x-android-drm-fl"),
169171
String8("application/vnd.oma.drm.message"),
@@ -184,17 +186,21 @@ void FwdLockEngine::AddSupportedFileSuffixes(DrmSupportInfo *info) {
184186
}
185187

186188
bool FwdLockEngine::IsMimeTypeSupported(const String8& mime) {
189+
String8 tmp(mime);
190+
tmp.toLower();
187191
for (size_t i = 0, n = sizeof(MimeTypes)/sizeof(MimeTypes[0]); i < n; ++i) {
188-
if (mime == MimeTypes[i]) {
192+
if (tmp == MimeTypes[i]) {
189193
return true;
190194
}
191195
}
192196
return false;
193197
}
194198

195199
bool FwdLockEngine::IsFileSuffixSupported(const String8& suffix) {
200+
String8 tmp(suffix);
201+
tmp.toLower();
196202
for (size_t i = 0, n = sizeof(FileSuffixes)/sizeof(FileSuffixes[0]); i < n; ++i) {
197-
if (suffix == FileSuffixes[i]) {
203+
if (tmp == FileSuffixes[i]) {
198204
return true;
199205
}
200206
}
@@ -220,7 +226,6 @@ bool FwdLockEngine::onCanHandle(int uniqueId, const String8& path) {
220226
bool result = false;
221227

222228
String8 extString = path.getPathExtension();
223-
extString.toLower();
224229
return IsFileSuffixSupported(extString);
225230
}
226231

@@ -331,8 +336,6 @@ int FwdLockEngine::onGetDrmObjectType(int uniqueId,
331336

332337
LOG_VERBOSE("FwdLockEngine::onGetDrmObjectType");
333338

334-
mimeStr.toLower();
335-
336339
/* Checks whether
337340
* 1. path and mime type both are not empty strings (meaning unavailable) else content is unknown
338341
* 2. if one of them is empty string and if other is known then its a DRM Content Object.

0 commit comments

Comments
 (0)