Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Fix accidental float/double NaN parsing in snbt
Dieser Commit ist enthalten in:
Ursprung
0a19057606
Commit
7cc6eb2b66
@ -277,10 +277,16 @@ final class TagStringReader {
|
|||||||
result = new LongTag(Long.parseLong(builder.toString()));
|
result = new LongTag(Long.parseLong(builder.toString()));
|
||||||
break;
|
break;
|
||||||
case Tokens.TYPE_FLOAT:
|
case Tokens.TYPE_FLOAT:
|
||||||
result = new FloatTag(Float.parseFloat(builder.toString()));
|
final float floatValue = Float.parseFloat(builder.toString());
|
||||||
|
if (!Float.isNaN(floatValue)) {
|
||||||
|
result = new FloatTag(floatValue);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Tokens.TYPE_DOUBLE:
|
case Tokens.TYPE_DOUBLE:
|
||||||
result = new DoubleTag(Double.parseDouble(builder.toString()));
|
final double doubleValue = Double.parseDouble(builder.toString());
|
||||||
|
if (!Double.isNaN(doubleValue)) {
|
||||||
|
result = new DoubleTag(doubleValue);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (final NumberFormatException ex) {
|
} catch (final NumberFormatException ex) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.common.nbt;
|
package com.viaversion.viaversion.common.nbt;
|
||||||
|
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ public class NBTTagTest {
|
|||||||
readString("{id:[I;1,2,3,]}");
|
readString("{id:[I;1,2,3,]}");
|
||||||
readString("{id:[1,2,3,]}");
|
readString("{id:[1,2,3,]}");
|
||||||
|
|
||||||
|
Assertions.assertEquals("NaNd", readString("{id:NaNd}").get("id").getValue());
|
||||||
Assertions.assertEquals("2147483649", readString("{id:9000b,thisisastring:2147483649}").get("thisisastring").getValue());
|
Assertions.assertEquals("2147483649", readString("{id:9000b,thisisastring:2147483649}").get("thisisastring").getValue());
|
||||||
Assertions.assertEquals((byte) 1, readString("{thisisabyte:true}").get("thisisabyte").getValue());
|
Assertions.assertEquals((byte) 1, readString("{thisisabyte:true}").get("thisisabyte").getValue());
|
||||||
Assertions.assertEquals((byte) 0, readString("{thisisabyte:false}").get("thisisabyte").getValue());
|
Assertions.assertEquals((byte) 0, readString("{thisisabyte:false}").get("thisisabyte").getValue());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren