Fix PHP serialization and add Long Text type to Visual Editor

- Fixed PHP serialization byte length calculation for escaped strings
- Added Long Text type with textarea for multiline strings in StructuredEditor
- Auto-detects strings with newlines and displays them as textarea
- Improvements apply to both SerializeTool and JsonTool visual editors
- Resolves parse errors with quoted strings and multiline content
This commit is contained in:
dwindown
2025-08-21 23:45:46 +07:00
parent 65cc3bc54d
commit 6f5bdf5f0d
2 changed files with 33 additions and 13 deletions

View File

@@ -21,7 +21,11 @@ const SerializeTool = () => {
return Number.isInteger(data) ? `i:${data};` : `d:${data};`;
}
if (typeof data === 'string') {
return `s:${data.length}:"${data}";`;
// Escape quotes and backslashes in the string first
const escapedData = data.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
// PHP serialize requires UTF-8 byte length of the ESCAPED string
const byteLength = new TextEncoder().encode(escapedData).length;
return `s:${byteLength}:"${escapedData}";`;
}
if (Array.isArray(data)) {
let result = `a:${data.length}:{`;