nopCommerce
nopCommerce copied to clipboard
Possible error downloading files when importing products
nopCommerce version: 4.30
The
Uri.IsWellFormedUriString
function sometimes returns a false negative depending on the characters in the URI (see https://github.com/dotnet/runtime/issues/21626). In my case some image file names had the ^ character in it. The workaround I am using is to url encode the image string before checking if it is a valid uri. I also had to change uri kind fromAbsolute
toRelativeOrAbsolute
for it to work.
In the Nop.Services/ExportImport/ImportManager.cs file I changed the function DownloadFile as follows:
Before:
if (!Uri.IsWellFormedUriString(urlString, UriKind.Absolute)) return urlString;
After:
var encodedUrl = System.Web.HttpUtility.UrlEncode(urlString); if (!Uri.IsWellFormedUriString(encodedUrl, UriKind.RelativeOrAbsolute)) return urlString;
Source: https://www.nopcommerce.com/boards/topic/79591/product_picture_mapping-issue#280288
Decided not to come up with workarounds and wait for dotnet team to fix this bug.
We are waiting for a solution to the #72632 ticket from the dotnet team