Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/components/viewers/ViewerPHPSerialize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ export default {
data() {
return {
isPHPClass: false,
isThinkphpSerialize: false,
};
},
components: { JsonEditor },
computed: {
newContent() {
try {
const content = unserialize(this.content, {}, { strict: false });
// 支持 thinkphp 序列化前缀处理
let rawContent = this.content.toString();
this.isThinkphpSerialize = rawContent.startsWith('think_serialize:');
if (this.isThinkphpSerialize) {
rawContent = rawContent.replace(/^think_serialize:/, '');
}

const content = unserialize(rawContent, {}, { strict: false });

if (content && content['__PHP_Incomplete_Class_Name']) {
this.isPHPClass = true;
Expand Down Expand Up @@ -48,8 +56,12 @@ export default {
return false;
}
}

return serialize(content);
let serializedContent = serialize(content);
// 支持 thinkphp 序列化前缀处理
if (this.isThinkphpSerialize) {
serializedContent = `think_serialize:${serializedContent}`;
}
return serializedContent;
},
},
};
Expand Down
7 changes: 6 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ export default {

try {
// phpSerialize.unserialize(str);
return phpSerialize.isSerialized(str.toString());
// 支持 thinkphp 序列化前缀处理
const rawStr = str.toString();
if(rawStr.startsWith('think_serialize:')){
rawStr = rawStr.replace(/^think_serialize:/, '');
}
return phpSerialize.isSerialized(rawStr);
} catch (e) {}

return false;
Expand Down