STRATO-apps/wordpress_03/app/wp-content/plugins/blocksy-companion-pro/static/js/options/utils.js
SHA-256: 57a13049a50512efeb4cff8077ce128824ad0421ed8e027b467060b556055a71
import phpUnserialize from 'phpunserialize'
export const safePhpUnserialize = (data) => {
const fixed = data.replace(
/s:(\d+):"((?:\\.|[^"\\])*)";/g,
(_, len, str) => {
// If multiline, skip length correction to avoid breaking structure
if (str.includes('\n')) return `s:${len}:"${str}";`
const actualLength = Buffer.byteLength(str, 'utf8')
return `s:${actualLength}:"${str}";`
}
)
return phpUnserialize(fixed)
}