mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-27 03:33:45 +01:00 
			
		
		
		
	Merge pull request #2447 from ar-lex/bugfix/rustore-charset
RuStore: fix charset detection (#2304)
This commit is contained in:
		| @@ -36,13 +36,15 @@ class RuStore extends AppSource { | |||||||
|     return Uri.parse(standardUrl).pathSegments.last; |     return Uri.parse(standardUrl).pathSegments.last; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Future<String> decodeString(String str) async { |   Future<dynamic> decodeJsonBody(Uint8List bytes) async { | ||||||
|     try { |     try { | ||||||
|       return (await CharsetDetector.autoDecode( |       return jsonDecode((await CharsetDetector.autoDecode(bytes)).string); | ||||||
|         Uint8List.fromList(str.codeUnits), |  | ||||||
|       )).string; |  | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       return str; |       try { | ||||||
|  |         return jsonDecode(utf8.decode(bytes)); | ||||||
|  |       } catch (_) { | ||||||
|  |         rethrow; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -59,7 +61,7 @@ class RuStore extends AppSource { | |||||||
|     if (res0.statusCode != 200) { |     if (res0.statusCode != 200) { | ||||||
|       throw getObtainiumHttpError(res0); |       throw getObtainiumHttpError(res0); | ||||||
|     } |     } | ||||||
|     var appDetails = jsonDecode(res0.body)['body']; |     var appDetails = (await decodeJsonBody(res0.bodyBytes))['body']; | ||||||
|     if (appDetails['appId'] == null) { |     if (appDetails['appId'] == null) { | ||||||
|       throw NoReleasesError(); |       throw NoReleasesError(); | ||||||
|     } |     } | ||||||
| @@ -83,15 +85,11 @@ class RuStore extends AppSource { | |||||||
|       followRedirects: false, |       followRedirects: false, | ||||||
|       postBody: {"appId": appDetails['appId'], "firstInstall": true}, |       postBody: {"appId": appDetails['appId'], "firstInstall": true}, | ||||||
|     ); |     ); | ||||||
|     var downloadDetails = jsonDecode(res1.body)['body']; |     var downloadDetails = (await decodeJsonBody(res1.bodyBytes))['body']; | ||||||
|     if (res1.statusCode != 200 || downloadDetails['apkUrl'] == null) { |     if (res1.statusCode != 200 || downloadDetails['apkUrl'] == null) { | ||||||
|       throw NoAPKError(); |       throw NoAPKError(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     appName = await decodeString(appName); |  | ||||||
|     author = await decodeString(author); |  | ||||||
|     changeLog = changeLog != null ? await decodeString(changeLog) : null; |  | ||||||
|  |  | ||||||
|     return APKDetails( |     return APKDetails( | ||||||
|       version, |       version, | ||||||
|       getApkUrlsFromUrls([ |       getApkUrlsFromUrls([ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user