Remove Nett .Get<> methods from content.
They could allow bypassing sandbox due to how the deserialization logic works.
This commit is contained in:
@@ -44,18 +44,17 @@ namespace Content.Client.Parallax
|
||||
|
||||
private void _loadConfig(TomlTable config)
|
||||
{
|
||||
foreach (var layerArray in config.Get<TomlTableArray>("layers").Items)
|
||||
foreach (var layerArray in ((TomlTableArray)config.Get("layers")).Items)
|
||||
{
|
||||
var layer = layerArray.Get<TomlTable>();
|
||||
switch (layer.Get<string>("type"))
|
||||
switch (((TomlValue<string>) layerArray.Get("type")).Value)
|
||||
{
|
||||
case "noise":
|
||||
var layerNoise = new LayerNoise(layer);
|
||||
var layerNoise = new LayerNoise(layerArray);
|
||||
Layers.Add(layerNoise);
|
||||
break;
|
||||
|
||||
case "points":
|
||||
var layerPoint = new LayerPoints(layer);
|
||||
var layerPoint = new LayerPoints(layerArray);
|
||||
Layers.Add(layerPoint);
|
||||
break;
|
||||
|
||||
@@ -89,62 +88,62 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
if (table.TryGetValue("innercolor", out var tomlObject))
|
||||
{
|
||||
InnerColor = Color.FromHex(tomlObject.Get<string>());
|
||||
InnerColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("outercolor", out tomlObject))
|
||||
{
|
||||
OuterColor = Color.FromHex(tomlObject.Get<string>());
|
||||
OuterColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("seed", out tomlObject))
|
||||
{
|
||||
Seed = (uint) tomlObject.Get<int>();
|
||||
Seed = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("persistence", out tomlObject))
|
||||
{
|
||||
Persistence = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Persistence = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("lacunarity", out tomlObject))
|
||||
{
|
||||
Lacunarity = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Lacunarity = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("frequency", out tomlObject))
|
||||
{
|
||||
Frequency = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Frequency = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("octaves", out tomlObject))
|
||||
{
|
||||
Octaves = (uint) tomlObject.Get<int>();
|
||||
Octaves = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("threshold", out tomlObject))
|
||||
{
|
||||
Threshold = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Threshold = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("sourcefactor", out tomlObject))
|
||||
{
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("destfactor", out tomlObject))
|
||||
{
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("power", out tomlObject))
|
||||
{
|
||||
Power = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Power = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("noise_type", out tomlObject))
|
||||
{
|
||||
switch (tomlObject.Get<string>())
|
||||
switch (((TomlValue<string>) tomlObject).Value)
|
||||
{
|
||||
case "fbm":
|
||||
NoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||
@@ -226,78 +225,78 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
if (table.TryGetValue("seed", out var tomlObject))
|
||||
{
|
||||
Seed = tomlObject.Get<int>();
|
||||
Seed = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("count", out tomlObject))
|
||||
{
|
||||
PointCount = tomlObject.Get<int>();
|
||||
PointCount = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("sourcefactor", out tomlObject))
|
||||
{
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("destfactor", out tomlObject))
|
||||
{
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("farcolor", out tomlObject))
|
||||
{
|
||||
FarColor = Color.FromHex(tomlObject.Get<string>());
|
||||
FarColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("closecolor", out tomlObject))
|
||||
{
|
||||
CloseColor = Color.FromHex(tomlObject.Get<string>());
|
||||
CloseColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("pointsize", out tomlObject))
|
||||
{
|
||||
PointSize = tomlObject.Get<int>();
|
||||
PointSize = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
// Noise mask stuff.
|
||||
if (table.TryGetValue("mask", out tomlObject))
|
||||
{
|
||||
Masked = tomlObject.Get<bool>();
|
||||
Masked = ((TomlValue<bool>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskseed", out tomlObject))
|
||||
{
|
||||
MaskSeed = (uint) tomlObject.Get<int>();
|
||||
MaskSeed = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskpersistence", out tomlObject))
|
||||
{
|
||||
MaskPersistence = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskPersistence = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("masklacunarity", out tomlObject))
|
||||
{
|
||||
MaskLacunarity = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskLacunarity = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskfrequency", out tomlObject))
|
||||
{
|
||||
MaskFrequency = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskFrequency = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskoctaves", out tomlObject))
|
||||
{
|
||||
MaskOctaves = (uint) tomlObject.Get<int>();
|
||||
MaskOctaves = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskthreshold", out tomlObject))
|
||||
{
|
||||
MaskThreshold = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskThreshold = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("masknoise_type", out tomlObject))
|
||||
{
|
||||
switch (tomlObject.Get<string>())
|
||||
switch (((TomlValue<string>) tomlObject).Value)
|
||||
{
|
||||
case "fbm":
|
||||
MaskNoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||
@@ -312,7 +311,7 @@ namespace Content.Client.Parallax
|
||||
|
||||
if (table.TryGetValue("maskpower", out tomlObject))
|
||||
{
|
||||
MaskPower = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskPower = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user