Skip to content

Commit a7b9a5f

Browse files
committed
parsePerms(): compensate for rare 3rd block in protobuf for "other other" perms
1 parent 43057a6 commit a7b9a5f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

google-play.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,19 @@ public function parsePerms($packageName,$lang='en') {
140140
$json = preg_replace('!.*?(\[.+?\])\s*\d.*!ims','$1',$proto);
141141
$arr = json_decode(json_decode($json)[0][2]);
142142
if (!empty($arr[0])) foreach ($arr[0] as $group) { // 0: group name, 1: group icon, 2: perms, 3: group_id
143+
if (empty($group)) continue;
143144
$perms[$group[3][0]] = ['group_name'=>$group[0], 'perms'=>$group[2]];
144145
foreach($group[2] as $perm) $perms_unique[] = $perm[1];
145146
}
146147
if (!empty($arr[1])) {
147148
$perms['misc'] = ['group_name'=>$arr[1][0][0], 'perms'=>$arr[1][0][2]];
148149
foreach($arr[1][0][2] as $perm) $perms_unique[] = $perm[1];
149150
}
151+
if (!empty($arr[2])) {
152+
if (array_key_exists('misc',$perms)) $perms['misc']['perms'] = array_merge($perms['misc']['perms'],$arr[2]);
153+
else $perms['misc'] = ['group_name'=>$arr[1][0][0], 'perms'=>$arr[2]];
154+
foreach($arr[2] as $perm) $perms_unique[] = $perm[1];
155+
}
150156

151157
return ['success'=>1,'grouped'=>$perms,'perms'=>array_unique($perms_unique)];
152158
}

0 commit comments

Comments
 (0)