diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index cda25fb65..cc0bda2ed 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -270,6 +270,15 @@ namespace PascalABCCompiler } } + public class InvalidPathError : CompilerCompilationError + { + public InvalidPathError(SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_INVALID_PATH"))) + { + this.source_context = sc; + } + } + public class ResourceFileNotFound : CompilerCompilationError { public ResourceFileNotFound(string ResFileName, TreeRealization.location sl) @@ -1812,7 +1821,19 @@ namespace PascalABCCompiler CompilerOptions.OutputDirectory = project.output_directory; } - public string Compile() + private static string CombinePathWithCheck(string path1, string path2, location loc) + { + try + { + return Path.Combine(path1, path2); + } + catch (Exception ex) + { + throw new InvalidPathError(loc); + } + } + + public string Compile() { try @@ -2007,7 +2028,7 @@ namespace PascalABCCompiler { ErrorsList.Add(new MainResourceNotAllowed(cds[0].location)); } - cdo.MainResourceFileName = Path.Combine(Path.GetDirectoryName(cds[0].source_file), cds[0].directive); + cdo.MainResourceFileName = CombinePathWithCheck(Path.GetDirectoryName(cds[0].source_file), cds[0].directive, cds[0].location); if (!File.Exists(cdo.MainResourceFileName)) { ErrorsList.Add(new ResourceFileNotFound(cds[0].directive, cds[0].location)); @@ -2021,7 +2042,7 @@ namespace PascalABCCompiler List ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource]; foreach (TreeRealization.compiler_directive cd in ResourceDirectives) { - var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive); + var resource_fname = CombinePathWithCheck(Path.GetDirectoryName(cd.source_file), cd.directive, cd.location); if (File.Exists(resource_fname)) ResourceFiles.Add(resource_fname); @@ -2275,6 +2296,7 @@ namespace PascalABCCompiler } catch (Exception err) { + string fn = "Compiler"; if (CurrentCompilationUnit != null && this.CurrentCompilationUnit.SyntaxTree != null) fn = Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name); Errors.CompilerInternalError comp_err = new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", fn), err); @@ -2635,7 +2657,7 @@ namespace PascalABCCompiler // Вначале - кешированные стандартные dll if (standart_assembly_dict.ContainsKey(FileName)) return standart_assembly_dict[FileName]; - if (curr_path != null && System.IO.File.Exists(Path.Combine(curr_path, FileName))) + if (curr_path != null && System.IO.File.Exists(Path.Combine(curr_path, FileName, null))) return Path.Combine(curr_path, FileName); if (System.IO.File.Exists(FileName)) { @@ -2664,7 +2686,7 @@ namespace PascalABCCompiler } //\MikhailoMMX - var FullFileName = Path.Combine(curr_path, FileName); + var FullFileName = CombinePathWithCheck(curr_path, FileName, new location(sc.begin_position.line_num, sc.begin_position.column_num, sc.end_position.line_num, sc.end_position.column_num, new document(sc.FileName))); if (System.IO.File.Exists(FullFileName)) { var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index ac131a9ad..a179a83b6 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "8"; public const string Build = "3"; - public const string Revision = "3250"; + public const string Revision = "3251"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 526f9a8f4..385b1bfb2 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=3 -%REVISION%=3250 %MINOR%=8 +%REVISION%=3251 +%COREVERSION%=3 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 81f91a02f..6dd3adbc7 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index e028433d0..2f9591114 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.8.3.3250 +3.8.3.3251 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index eac61340f..2ba9c359f 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.8.3.3250' +!define VERSION '3.8.3.3251' diff --git a/TestSuite/errors/err0518_invalid_path.pas b/TestSuite/errors/err0518_invalid_path.pas new file mode 100644 index 000000000..56cbd1715 --- /dev/null +++ b/TestSuite/errors/err0518_invalid_path.pas @@ -0,0 +1,5 @@ +//!Путь содержит недопустимые символы +{$mainresource '|'} +begin + +end. diff --git a/bin/Lng/Eng/SemanticErrors_ib.dat b/bin/Lng/Eng/SemanticErrors_ib.dat index 99ac21375..e82e556fd 100644 --- a/bin/Lng/Eng/SemanticErrors_ib.dat +++ b/bin/Lng/Eng/SemanticErrors_ib.dat @@ -181,5 +181,6 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Cannot deduce type of anonym UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Unit expected, library found ASSEMBLY_{0}_READING_ERROR=Error by reading assembly '{0}' INVALID_ASSEMBLY_PATH=Assembly path has invalid characters +INVALID_PATH=The path has invalid characters INCLUDE_NAMESPACE_IN_UNIT=Cannot use includenamespace in units NAMESPACE_MODULE_EXPECTED=namespace expected \ No newline at end of file diff --git a/bin/Lng/Rus/SemanticErrors_ib.dat b/bin/Lng/Rus/SemanticErrors_ib.dat index d9a0f5adf..7b2677870 100644 --- a/bin/Lng/Rus/SemanticErrors_ib.dat +++ b/bin/Lng/Rus/SemanticErrors_ib.dat @@ -175,6 +175,7 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Нельзя вывести %PREFIX%=COMPILATIONERROR_ UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}' -INVALID_ASSEMBLY_PATH=Путь к сборке имеет недопустимые символы +INVALID_ASSEMBLY_PATH=Путь к сборке содержит недопустимые символы +INVALID_PATH=Путь содержит недопустимые символы INCLUDE_NAMESPACE_IN_UNIT=Использование includenamespace в модулях недопустимо NAMESPACE_MODULE_EXPECTED=Ожидалось пространство имен \ No newline at end of file diff --git a/bin/Lng/Ukr/SemanticErrors_ib.dat b/bin/Lng/Ukr/SemanticErrors_ib.dat index 79ccc4a38..4cd5320e4 100644 --- a/bin/Lng/Ukr/SemanticErrors_ib.dat +++ b/bin/Lng/Ukr/SemanticErrors_ib.dat @@ -173,5 +173,6 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Нельзя вывести UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Очікувався модуль, а зустріли бібліотеку ASSEMBLY_{0}_READING_ERROR=Помилка при читанні збірки '{0}' INVALID_ASSEMBLY_PATH=Шлях до збірки має неприпустимі символи +INVALID_PATH=Шлях має неприпустимі символи INCLUDE_NAMESPACE_IN_UNIT=Использование includenamespace в модулях недопустимо NAMESPACE_MODULE_EXPECTED=Ожидалось пространство имен \ No newline at end of file