Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -34,24 +34,32 @@ def sign():
|
|
| 34 |
p12.save(p12_path)
|
| 35 |
prov.save(prov_path)
|
| 36 |
|
| 37 |
-
# ---
|
| 38 |
-
# We
|
| 39 |
-
|
| 40 |
f"unzip -p {ipa_path} Payload/*.app/Info.plist",
|
| 41 |
-
shell=True, capture_output=True
|
| 42 |
).stdout
|
| 43 |
|
|
|
|
|
|
|
|
|
|
| 44 |
# Extract Bundle ID
|
| 45 |
-
|
|
|
|
| 46 |
bundle_id = id_match.group(1).strip() if id_match else "com.simplebit.dynamic"
|
| 47 |
|
| 48 |
-
# Extract App Name
|
| 49 |
-
name_match = re.search(r"
|
| 50 |
if not name_match:
|
| 51 |
-
name_match = re.search(r"
|
| 52 |
|
| 53 |
app_name = name_match.group(1).strip() if name_match else "Signed App"
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
# Sign the app
|
| 56 |
command = [
|
| 57 |
"zsign",
|
|
|
|
| 34 |
p12.save(p12_path)
|
| 35 |
prov.save(prov_path)
|
| 36 |
|
| 37 |
+
# --- FIXED Extraction Method for Binary Plists ---
|
| 38 |
+
# We read as binary (capture_output=True) and decode safely to avoid UnicodeDecodeError
|
| 39 |
+
raw_plist = subprocess.run(
|
| 40 |
f"unzip -p {ipa_path} Payload/*.app/Info.plist",
|
| 41 |
+
shell=True, capture_output=True
|
| 42 |
).stdout
|
| 43 |
|
| 44 |
+
# Decode using latin-1 or ignore errors to handle binary bloat around the strings
|
| 45 |
+
plist_content = raw_plist.decode('utf-8', errors='ignore')
|
| 46 |
+
|
| 47 |
# Extract Bundle ID
|
| 48 |
+
# We use a more relaxed regex because binary plists might have null bytes between characters
|
| 49 |
+
id_match = re.search(r"CFBundleIdentifier.*?<string>(.*?)</string>", plist_content, re.DOTALL)
|
| 50 |
bundle_id = id_match.group(1).strip() if id_match else "com.simplebit.dynamic"
|
| 51 |
|
| 52 |
+
# Extract App Name
|
| 53 |
+
name_match = re.search(r"CFBundleDisplayName.*?<string>(.*?)</string>", plist_content, re.DOTALL)
|
| 54 |
if not name_match:
|
| 55 |
+
name_match = re.search(r"CFBundleName.*?<string>(.*?)</string>", plist_content, re.DOTALL)
|
| 56 |
|
| 57 |
app_name = name_match.group(1).strip() if name_match else "Signed App"
|
| 58 |
|
| 59 |
+
# Clean up any potential XML tags left in strings
|
| 60 |
+
bundle_id = re.sub('<[^<]+?>', '', bundle_id)
|
| 61 |
+
app_name = re.sub('<[^<]+?>', '', app_name)
|
| 62 |
+
|
| 63 |
# Sign the app
|
| 64 |
command = [
|
| 65 |
"zsign",
|