Fix crash issue when trying to parse bad skin JSON#3712
Open
TheSharkyOfficial wants to merge 17 commits intoPrismarineJS:masterfrom
Open
Fix crash issue when trying to parse bad skin JSON#3712TheSharkyOfficial wants to merge 17 commits intoPrismarineJS:masterfrom
TheSharkyOfficial wants to merge 17 commits intoPrismarineJS:masterfrom
Conversation
Bad JSON sometimes occur with NPC players on servers
Member
|
That should be using mojangson |
Member
Member
|
Please remove this custom parsing and use https://github.com/PrismarineJS/node-mojangson instead |
Omena0
suggested changes
Aug 11, 2025
Contributor
Omena0
left a comment
There was a problem hiding this comment.
Please fix the linting errors.
Contributor
|
bump, this thing still crashes bot without fix |
Contributor
Author
|
this should fix the crash now |
Omena0
approved these changes
Oct 26, 2025
rom1504
reviewed
Oct 26, 2025
lib/plugins/entities.js
Outdated
|
|
||
| const skinTexture = JSON.parse(Buffer.from(props.textures.value, 'base64').toString('utf8')) | ||
|
|
||
| const skinTexture = JSON.parse(mojangson.parse(Buffer.from(props.textures.value, 'base64').toString('utf8'))) |
Member
There was a problem hiding this comment.
the .toString('utf8' and json parse is not necessary
Contributor
Author
There was a problem hiding this comment.
I just made and tested a new fix, because mojangson can't parse JSON, and also only for mojangson formatted skins .toString('utf8') is required because otherwise it would give hex data
Member
|
Can you add a test ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bad skin JSON sometimes occur with NPC players on servers, this will fix the JSON by adding missing quotes if found.
Example of JSON of a NPC player (notice the missing quotes) :
For comparison, this is what a normal player skin data looks like :