ErikHen / PictureRenderer

Simplify the rendering of HTML Picture elements for ASP.Net. With support for responsive, lazy loaded images.
MIT License
4 stars 5 forks source link

Uri.IsWellFormedUriString false negative #12

Closed jasylvarnes closed 1 year ago

jasylvarnes commented 1 year ago

PictureUtils.cs:192 uses Uri.IsWellFormedUriString() to check if url's are well formatted, but the method contains a known bug, and is not reccomended for this usecase (https://github.com/dotnet/runtime/issues/72632).

The suggested workaround in the issue above is:

static bool IsValidHttpUri(string uriString, out Uri uri) =>
    Uri.TryCreate(uriString, UriKind.Absolute, out uri) &&
    (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);

Uri.IsWellFormedUriString() uses Uri.TryCreate() internally so this will not add any new workload

ErikHen commented 1 year ago

Thanks for pointing that out. I will look into this shortly.