add defensive logic to route parsing

This commit is contained in:
sbwalker 2024-05-13 08:45:03 -04:00
parent d57c1e7ff0
commit e86ce8fc38

View File

@ -42,14 +42,20 @@ namespace Oqtane.Models
} }
int pos = PagePath.IndexOf("/" + Constants.UrlParametersDelimiter + "/"); int pos = PagePath.IndexOf("/" + Constants.UrlParametersDelimiter + "/");
if (pos != -1) if (pos != -1)
{
if (pos + 3 < PagePath.Length)
{ {
UrlParameters = PagePath.Substring(pos + 3); UrlParameters = PagePath.Substring(pos + 3);
}
PagePath = PagePath.Substring(0, pos); PagePath = PagePath.Substring(0, pos);
} }
pos = PagePath.IndexOf("/" + Constants.ModuleDelimiter + "/"); pos = PagePath.IndexOf("/" + Constants.ModuleDelimiter + "/");
if (pos != -1) if (pos != -1)
{
if (pos + 3 < PagePath.Length)
{ {
ModuleId = PagePath.Substring(pos + 3); ModuleId = PagePath.Substring(pos + 3);
}
PagePath = PagePath.Substring(0, pos); PagePath = PagePath.Substring(0, pos);
} }
if (ModuleId.Length != 0) if (ModuleId.Length != 0)