|
1 | 1 | package com.fox2code.mmm.repo; |
2 | 2 |
|
3 | 3 | import android.content.SharedPreferences; |
| 4 | +import android.text.TextUtils; |
4 | 5 |
|
5 | 6 | import com.fox2code.mmm.manager.ModuleInfo; |
6 | 7 | import com.fox2code.mmm.utils.Files; |
@@ -66,6 +67,8 @@ List<RepoModule> populate(JSONObject jsonObject) throws JSONException { |
66 | 67 | for (int i = 0; i < len; i++) { |
67 | 68 | JSONObject module = array.getJSONObject(i); |
68 | 69 | String moduleId = module.getString("id"); |
| 70 | + // Deny remote modules ids shorter than 3 chars long or that start with a digit |
| 71 | + if (moduleId.length() < 3 || Character.isDigit(moduleId.charAt(0))) continue; |
69 | 72 | long moduleLastUpdate = module.getLong("last_update"); |
70 | 73 | String moduleNotesUrl = module.getString("notes_url"); |
71 | 74 | String modulePropsUrl = module.getString("prop_url"); |
@@ -108,8 +111,12 @@ public boolean tryLoadMetadata(RepoModule repoModule) { |
108 | 111 | File file = new File(this.cacheRoot, repoModule.id + ".prop"); |
109 | 112 | if (file.exists()) { |
110 | 113 | try { |
111 | | - PropUtils.readProperties(repoModule.moduleInfo, file.getAbsolutePath()); |
112 | | - repoModule.moduleInfo.flags &= ~ModuleInfo.FLAG_METADATA_INVALID; |
| 114 | + ModuleInfo moduleInfo = repoModule.moduleInfo; |
| 115 | + PropUtils.readProperties(moduleInfo, file.getAbsolutePath()); |
| 116 | + moduleInfo.flags &= ~ModuleInfo.FLAG_METADATA_INVALID; |
| 117 | + if (moduleInfo.version == null) { |
| 118 | + moduleInfo.version = "v" + moduleInfo.versionCode; |
| 119 | + } |
113 | 120 | return true; |
114 | 121 | } catch (Exception ignored) { |
115 | 122 | file.delete(); |
|
0 commit comments