Skip to content

Commit

Permalink
fix(parse_app_package): fix failure to parse Property List Binary f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
lijy91 committed Apr 3, 2024
1 parent 3c03a4a commit 302f715
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 98 deletions.
2 changes: 1 addition & 1 deletion examples/hello_world/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
8 changes: 4 additions & 4 deletions examples/hello_world/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -340,7 +340,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = G83H824X6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -469,7 +469,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = G83H824X6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -492,7 +492,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = G83H824X6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
50 changes: 13 additions & 37 deletions examples/hello_world/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -111,34 +87,34 @@ packages:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.8.3"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -200,13 +176,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
web:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "0.3.0"
sdks:
dart: ">=3.2.0-0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
4 changes: 4 additions & 0 deletions packages/flutter_app_publisher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0

* bump `parse_app_package` to 0.4.0

## 0.3.6

* bump `shell_executor` to 0.1.5
Expand Down
10 changes: 9 additions & 1 deletion packages/flutter_app_publisher/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ packages:
path: "../parse_app_package"
relative: true
source: path
version: "0.3.6"
version: "0.4.0"
path:
dependency: transitive
description:
Expand All @@ -222,6 +222,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
plist_parser:
dependency: transitive
description:
name: plist_parser
sha256: e2a6f9abfa0c45c0253656b7360abb0dfb84af9937bace74605b93d2aad2bf0c
url: "https://pub.dev"
source: hosted
version: "0.0.11"
pointycastle:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_app_publisher/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_app_publisher
description: Flutter app publisher
version: 0.3.6
version: 0.4.0
homepage: https://distributor.leanflutter.org
repository: https://github.com/leanflutter/flutter_distributor/tree/main/packages/flutter_app_publisher

Expand All @@ -12,7 +12,7 @@ dependencies:
dio: ^5.3.4
googleapis: ^9.1.0
googleapis_auth: ^1.3.1
parse_app_package: ^0.3.6
parse_app_package: ^0.4.0
qiniu_sdk_base: ^0.5.0
shell_executor: ^0.1.5
dev_dependencies:
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter_distributor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0

* fix failure to parse `Property List Binary` format

## 0.3.9

* fix: Can't decode gbk encoding issue #131
Expand Down
12 changes: 10 additions & 2 deletions packages/flutter_distributor/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ packages:
path: "../flutter_app_publisher"
relative: true
source: path
version: "0.3.6"
version: "0.4.0"
frontend_server_client:
dependency: transitive
description:
Expand Down Expand Up @@ -377,7 +377,7 @@ packages:
path: "../parse_app_package"
relative: true
source: path
version: "0.3.6"
version: "0.4.0"
path:
dependency: "direct main"
description:
Expand All @@ -394,6 +394,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
plist_parser:
dependency: transitive
description:
name: plist_parser
sha256: e2a6f9abfa0c45c0253656b7360abb0dfb84af9937bace74605b93d2aad2bf0c
url: "https://pub.dev"
source: hosted
version: "0.0.11"
pointycastle:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_distributor/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_distributor
description: A complete tool for packaging and publishing your Flutter apps.
version: 0.3.8
version: 0.4.0
homepage: https://distributor.leanflutter.org
repository: https://github.com/leanflutter/flutter_distributor/tree/main/packages/flutter_distributor
issue_tracker: https://github.com/leanflutter/flutter_distributor/issues
Expand All @@ -22,7 +22,7 @@ dependencies:
dio: ^5.3.4
flutter_app_builder: ^0.3.7
flutter_app_packager: ^0.3.7
flutter_app_publisher: ^0.3.6
flutter_app_publisher: ^0.4.0
logging: ^1.0.2
path: ^1.8.1
pubspec_parse: ^1.1.0
Expand Down
4 changes: 4 additions & 0 deletions packages/parse_app_package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0

* fix failure to parse `Property List Binary` format

## 0.3.8

* bump `archive` to 3.4.10
Expand Down
2 changes: 1 addition & 1 deletion packages/parse_app_package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

```yaml
dependencies:
parse_app_package: ^0.3.6
parse_app_package: ^0.4.0
```
## Usage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,33 @@
import 'dart:convert';
import 'dart:io';

import 'package:app_package_parser/app_package_parser.dart';
import 'package:archive/archive.dart';
import 'package:archive/archive_io.dart';
import 'package:xml/xml.dart';
import 'package:plist_parser/plist_parser.dart';

class AppPackageParserIpa extends AppPackageParser {
@override
String get name => 'ipa';

_handleElem(XmlElement el) {
switch (el.name.local) {
case 'string':
return el.value;
case 'real':
return double.parse(el.value!);
case 'integer':
return int.parse(el.value!);
case 'true':
return true;
case 'false':
return false;
case 'date':
return DateTime.parse(el.value!);
}
}

@override
Future<AppPackage> parse(File file) async {
final ipaBytes = file.readAsBytesSync();
final archive = ZipDecoder().decodeBytes(ipaBytes);

String xmlString = '';
Map<dynamic, dynamic>? result;
for (final item in archive) {
if (item.isFile && item.name.endsWith('.app/Info.plist')) {
final data = item.content as List<int>;
xmlString = utf8.decode(data);
final data = item.content;
result = PlistParser().parseBytes(data);
break;
}
}

XmlDocument xmlDoc = XmlDocument.parse(xmlString);
XmlElement elPlist = xmlDoc.getElement('plist')!;
XmlElement elDict = elPlist.getElement('dict')!;

List<String> keys = elDict.childElements
.where((e) => e.name.local == 'key')
.map((e) => e.value!)
.toList();
List<dynamic> values = elDict.childElements
.where((e) => e.name.local != 'key')
.map(_handleElem)
.toList();
Map dict = Map.fromIterables(keys, values);

AppPackage appPackage = AppPackage(
if (result == null) throw Exception('Can\'t parse .ipa file.');
return AppPackage(
platform: 'ios',
identifier: dict['CFBundleIdentifier'],
name: dict['CFBundleDisplayName'],
version: dict['CFBundleShortVersionString'],
buildNumber: int.parse(dict['CFBundleVersion']),
identifier: result['CFBundleIdentifier'],
name: result['CFBundleDisplayName'],
version: result['CFBundleShortVersionString'],
buildNumber: int.parse(result['CFBundleVersion']),
);
return appPackage;
}
}
10 changes: 9 additions & 1 deletion packages/parse_app_package/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
plist_parser:
dependency: "direct main"
description:
name: plist_parser
sha256: e2a6f9abfa0c45c0253656b7360abb0dfb84af9937bace74605b93d2aad2bf0c
url: "https://pub.dev"
source: hosted
version: "0.0.11"
pointycastle:
dependency: transitive
description:
Expand Down Expand Up @@ -224,7 +232,7 @@ packages:
source: hosted
version: "1.3.2"
xml:
dependency: "direct main"
dependency: transitive
description:
name: xml
sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
Expand Down
4 changes: 2 additions & 2 deletions packages/parse_app_package/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: parse_app_package
description: Parse app package
version: 0.3.6
version: 0.4.0
homepage: https://distributor.leanflutter.org
repository: https://github.com/leanflutter/flutter_distributor/tree/main/packages/parse_app_package

Expand All @@ -11,8 +11,8 @@ dependencies:
app_package_parser: ^0.2.4
archive: ^3.4.10
args: ^2.2.0
plist_parser: ^0.0.11
shell_executor: ^0.1.5
xml: ^6.3.0

executables:
parse_app_package: main
Expand Down

0 comments on commit 302f715

Please sign in to comment.