Skip to content

[Improvement]: getDefineStringArray does not sanitize array input #435

Description

@CharGoldenYT

when using polymod.util.DefineUtil.getDefineStringArray, if (for some reason) the define input is ['array', 'items']

you get [['array', 'items']] when parsed

a quick edit to the function like as shown below, could remedy this (small change is why its an issue not a pr)

public static function getDefineStringArrayRaw(key:String, ?defaultValue:Array<String>):Array<String> {
		if (defaultValue == null)
			defaultValue = new Array<String>();
		var value = Context.definedValue(key);
		if (value != null)
		{
			var str:String = cast value;
			value = str.replace("[", "").replace("]", "");
		}
		return value == null ? defaultValue : value.split(',');
	}

of course this does not account for strings inside potentially being the result "'string'" (and vice-versa) and requires using StringTools;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions