|
15 | 15 | using System.Reflection; |
16 | 16 | using System.Security.Cryptography; |
17 | 17 | using System.Text; |
| 18 | +using System.Text.RegularExpressions; |
18 | 19 | using System.Web.Script.Serialization; |
19 | 20 |
|
20 | 21 | namespace LuaDkmDebuggerComponent |
@@ -1019,29 +1020,36 @@ string CheckConfigPaths(string processPath, LuaLocalProcessData processData, str |
1019 | 1020 | { |
1020 | 1021 | var finalPath = path.Replace('/', '\\'); |
1021 | 1022 |
|
1022 | | - if (!Path.IsPathRooted(finalPath)) |
| 1023 | + try |
1023 | 1024 | { |
1024 | | - if (processData.workingDirectory != null) |
| 1025 | + if (!Path.IsPathRooted(finalPath)) |
1025 | 1026 | { |
1026 | | - string test = Path.GetFullPath(Path.Combine(processData.workingDirectory, finalPath)) + winSourcePath; |
| 1027 | + if (processData.workingDirectory != null) |
| 1028 | + { |
| 1029 | + string test = Path.GetFullPath(Path.GetFullPath(Path.Combine(processData.workingDirectory, finalPath)) + winSourcePath); |
1027 | 1030 |
|
1028 | | - if (File.Exists(test)) |
1029 | | - return test; |
1030 | | - } |
| 1031 | + if (File.Exists(test)) |
| 1032 | + return test; |
| 1033 | + } |
| 1034 | + |
| 1035 | + { |
| 1036 | + string test = Path.GetFullPath(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(processPath), finalPath)) + winSourcePath); |
1031 | 1037 |
|
| 1038 | + if (File.Exists(test)) |
| 1039 | + return test; |
| 1040 | + } |
| 1041 | + } |
| 1042 | + else |
1032 | 1043 | { |
1033 | | - string test = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(processPath), finalPath)) + winSourcePath; |
| 1044 | + string test = Path.GetFullPath(finalPath + winSourcePath); |
1034 | 1045 |
|
1035 | 1046 | if (File.Exists(test)) |
1036 | 1047 | return test; |
1037 | 1048 | } |
1038 | 1049 | } |
1039 | | - else |
| 1050 | + catch (Exception e) |
1040 | 1051 | { |
1041 | | - string test = finalPath + winSourcePath; |
1042 | | - |
1043 | | - if (File.Exists(test)) |
1044 | | - return test; |
| 1052 | + log.Debug($"Exception while checking search path '{finalPath}': {e.Message}"); |
1045 | 1053 | } |
1046 | 1054 | } |
1047 | 1055 | } |
@@ -1105,7 +1113,9 @@ string TryFindSourcePath(string processPath, LuaLocalProcessData processData, st |
1105 | 1113 | // If we have source data, write it to the temp directory and return it |
1106 | 1114 | if (content != null && content.Length != 0) |
1107 | 1115 | { |
1108 | | - string tempPath = $"{Path.GetTempPath()}{winSourcePath.Replace('\\', '+')}"; |
| 1116 | + string pattern = "[<>:\"/\\\\\\|\\?\\*]"; |
| 1117 | + string cleanPath = Regex.Replace(winSourcePath, pattern, "+"); |
| 1118 | + string tempPath = $"{Path.GetTempPath()}{cleanPath}"; |
1109 | 1119 |
|
1110 | 1120 | if (!tempPath.EndsWith(".lua")) |
1111 | 1121 | tempPath += ".lua"; |
|
0 commit comments