gabefromsimplebit commited on
Commit
b9b5f80
·
verified ·
1 Parent(s): 3f46b26

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -34,24 +34,32 @@ def sign():
34
  p12.save(p12_path)
35
  prov.save(prov_path)
36
 
37
- # --- Working Extraction Method ---
38
- # We use the same 'unzip -p' logic to get both ID and Name
39
- plist_data = subprocess.run(
40
  f"unzip -p {ipa_path} Payload/*.app/Info.plist",
41
- shell=True, capture_output=True, text=True
42
  ).stdout
43
 
 
 
 
44
  # Extract Bundle ID
45
- id_match = re.search(r"<key>CFBundleIdentifier</key>\s*<string>(.*?)</string>", plist_data)
 
46
  bundle_id = id_match.group(1).strip() if id_match else "com.simplebit.dynamic"
47
 
48
- # Extract App Name (Checks Display Name first, then falling back to Bundle Name)
49
- name_match = re.search(r"<key>CFBundleDisplayName</key>\s*<string>(.*?)</string>", plist_data)
50
  if not name_match:
51
- name_match = re.search(r"<key>CFBundleName</key>\s*<string>(.*?)</string>", plist_data)
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",