Redirect URL Management crashes when umbracoRedirectUrl.Url contains no / character

The Redirect URL Management page crashes if there is a malformed row in the umbracoRedirectUrl table where the Url value does not contain a /.

I tracked this down to NewDefaultUrlProvider.GetUrlFromRoute, which assumes the route format is always {contentId}/{path} and does not guard against invalid input.
Root cause
Decompiled logic in NewDefaultUrlProvider.GetUrlFromRoute:

int num = route.IndexOf('/', StringComparison.Ordinal); // returns -1 for "1226#"
if (num != 0)
{
    text = route.Substring(num, route.Length - num);   // Substring(-1, ...) throws
}

When route is {id}#, IndexOf('/') returns -1.
Because the condition is if (num != 0), the code proceeds into Substring(-1, ...), which throws an ArgumentOutOfRangeException.

Why this is a bug
The method assumes every route contains a /, but malformed data can exist in the table. A missing bounds check causes the entire Redirect URL Management page to fail during serialization instead of safely ignoring or handling the invalid row.
Suggested fix
In NewDefaultUrlProvider.GetUrlFromRoute, change the condition from:

if (num != 0)

to:

if (num > 0)

That would prevent Substring from being called with -1.

Sounds like a bug! Please head here to report: Issues · umbraco/Umbraco-CMS · GitHub

Hi @VargyasMoniLajos

I’ve submitted a PR to fix this.

Regards,

Justin