mirror of
https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
synced 2025-07-05 12:58:47 +00:00
Merge branch 'braid/encoding' into 'main'
fix: support utf-16 encoding See merge request TheOneWithTheBraid/dart_pkpass!6
This commit is contained in:
commit
7578dc7352
5 changed files with 27 additions and 24 deletions
|
@ -1,7 +1,7 @@
|
||||||
variables:
|
variables:
|
||||||
FLUTTER_VERSION: 3.24.3
|
FLUTTER_VERSION: 3.29.2
|
||||||
|
|
||||||
image: registry.gitlab.com/theonewiththebraid/flutter-dockerimages:${FLUTTER_VERSION}-base
|
image: registry.gitlab.com/polycule_client/flutter-dockerimages:${FLUTTER_VERSION}-base
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- coverage
|
- coverage
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
## v2.2.0
|
||||||
|
|
||||||
|
- fix: support utf-16 encoding (The one with the braid)
|
||||||
|
|
||||||
## v2.1.4
|
## v2.1.4
|
||||||
|
|
||||||
- chore: bump SDK
|
- chore: bump SDK
|
||||||
|
|
|
@ -80,8 +80,10 @@ class PassBarcode {
|
||||||
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!;
|
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!;
|
||||||
return PassBarcode(
|
return PassBarcode(
|
||||||
format: _allowedFormats[json['format']]!,
|
format: _allowedFormats[json['format']]!,
|
||||||
barcodeData:
|
barcodeData: Uint8List.fromList(
|
||||||
Uint8List.fromList(messageEncoding.encode(json['message'] as String)),
|
messageEncoding
|
||||||
|
.encode((json['message'] as String).replaceAll('\\', '\\\\')),
|
||||||
|
),
|
||||||
messageEncoding: messageEncoding,
|
messageEncoding: messageEncoding,
|
||||||
altText: json['altText'] as String?,
|
altText: json['altText'] as String?,
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,7 +36,10 @@ class PassFile {
|
||||||
final file = archive.files
|
final file = archive.files
|
||||||
.singleWhere((element) => element.name == manifestEntry.key);
|
.singleWhere((element) => element.name == manifestEntry.key);
|
||||||
|
|
||||||
final content = file.byteContent;
|
final content = file.readBytes();
|
||||||
|
if (content == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String hash = sha1.convert(content).toString();
|
String hash = sha1.convert(content).toString();
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ class PassFile {
|
||||||
);
|
);
|
||||||
if (path == null) return null;
|
if (path == null) return null;
|
||||||
final file = _folder.singleWhere((element) => element.name == path);
|
final file = _folder.singleWhere((element) => element.name == path);
|
||||||
final content = file.byteContent;
|
final content = file.readBytes();
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,29 +122,25 @@ class PassFile {
|
||||||
extension on ArchiveFile {
|
extension on ArchiveFile {
|
||||||
String get stringContent {
|
String get stringContent {
|
||||||
final codec = Charset.detect(
|
final codec = Charset.detect(
|
||||||
byteContent,
|
readBytes()!,
|
||||||
defaultEncoding: utf8,
|
defaultEncoding: utf8,
|
||||||
orders: [
|
orders: [
|
||||||
utf8,
|
utf8,
|
||||||
ascii,
|
ascii,
|
||||||
gbk,
|
gbk,
|
||||||
latin1,
|
latin1,
|
||||||
|
utf16,
|
||||||
],
|
],
|
||||||
) ??
|
) ??
|
||||||
utf8;
|
utf8;
|
||||||
|
try {
|
||||||
return codec.decode(content);
|
return codec.decode(content);
|
||||||
|
} on FormatException {
|
||||||
|
// utf8 and utf16 are hard to distinguish
|
||||||
|
if (codec is Utf8Codec) {
|
||||||
|
return utf16.decode(content);
|
||||||
}
|
}
|
||||||
|
rethrow;
|
||||||
Uint8List get byteContent {
|
|
||||||
decompress();
|
|
||||||
|
|
||||||
final content = this.content;
|
|
||||||
if (content is String) {
|
|
||||||
return utf8.encode(content);
|
|
||||||
} else if (content is Iterable) {
|
|
||||||
return Uint8List.fromList(content.cast<int>().toList());
|
|
||||||
} else {
|
|
||||||
return rawContent!.toUint8List();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
name: pkpass
|
name: pkpass
|
||||||
description: A Dart native passbook parsing library supporting checksum verification, barcode parsing, localization and much more.
|
description: A Dart native passbook parsing library supporting checksum verification, barcode parsing, localization and much more.
|
||||||
version: 2.1.4
|
version: 2.2.0
|
||||||
repository: https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
|
repository: https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
|
||||||
homepage: https://gitlab.com/TheOneWithTheBraid/dart_pkpass
|
homepage: https://gitlab.com/TheOneWithTheBraid/dart_pkpass
|
||||||
issue_tracker: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/issues
|
issue_tracker: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/issues
|
||||||
funding:
|
funding:
|
||||||
- https://www.buymeacoffee.com/braid
|
- https://www.buymeacoffee.com/braid
|
||||||
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.4.0
|
sdk: ^3.4.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
archive: ^3.3.7
|
archive: ^4.0.5
|
||||||
barcode: ^2.2.4
|
barcode: ^2.2.4
|
||||||
charset: ^2.0.1
|
charset: ^2.0.1
|
||||||
crypto: ^3.0.3
|
crypto: ^3.0.3
|
||||||
http: ^1.0.0
|
http: ^1.0.0
|
||||||
intl: ">=0.17.0 <1.0.0"
|
intl: ">=0.17.0 <1.0.0"
|
||||||
|
|
||||||
|
|
||||||
topics:
|
topics:
|
||||||
- wallet
|
- wallet
|
||||||
- pkpass
|
- pkpass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue