PrismarineJS / prismarine-chat

A parser for a minecraft chat message
MIT License
34 stars 21 forks source link

Fix potential issue in toHTML #95

Closed extremeheat closed 1 year ago

extremeheat commented 1 year ago

Chat message may have a translate field, but with no with field. Fixes toHTML code trying to iterate over possibly undefined field

u9g commented 1 year ago

This is particularly worrying because we can't count on this.anything except for this.text, however we splice on a color string we don't know will exist earlier in the code: here, but this does fix the problem at hand.

extremeheat commented 1 year ago

If the color isn't in the cssDefaultStyles then the color pushed to cssProps will be undefined, yes. When .join(';') would be called the undefined will convert to an empty string that could appear as ;;color:rgb(200,0,0), for example. Excess semicolons are ignored in CSS so there shouldn't be any problem there.