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:
@@ -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}:{`;
|
||||
|
||||
Reference in New Issue
Block a user