ACS parser: fixed problem when trying to include files that contain invalid characters. Fixes #664

This commit is contained in:
biwa 2021-12-11 11:27:29 +01:00
parent 32acb551c3
commit a75249b315
2 changed files with 18 additions and 6 deletions

View file

@ -3046,14 +3046,22 @@ namespace CodeImp.DoomBuilder.Data
internal TextResourceData GetTextResourceData(string name)
{
// Filesystem path?
if(Path.IsPathRooted(name))
try
{
if(File.Exists(name))
if (Path.IsPathRooted(name))
{
DataLocation location = new DataLocation{ location = name, type = DataLocation.RESOURCE_DIRECTORY };
return new TextResourceData(File.OpenRead(name), location, name);
}
if (File.Exists(name))
{
DataLocation location = new DataLocation { location = name, type = DataLocation.RESOURCE_DIRECTORY };
return new TextResourceData(File.OpenRead(name), location, name);
}
return null;
}
}
catch (ArgumentException e)
{
// File and/or path contained illegal characters
return null;
}

View file

@ -2104,7 +2104,11 @@ namespace CodeImp.DoomBuilder
OnInclude = delegate(AcsParserSE se, string includefile, AcsParserSE.IncludeType includetype)
{
TextResourceData includedata = General.Map.Data.GetTextResourceData(includefile);
if(includedata == null) return false; // Fial
if (includedata == null)
{
General.ErrorLogger.Add(ErrorType.Error, "Could not find file to include while loading " + maplumpinfo.Name + ": " + includefile);
return false; // Fail
}
return se.Parse(includedata, true, includetype, false);
}
};