Edit/Update in Product Attribute Listing page ( grid) , it throws an error due to encoded string in the default value.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Kindly please fix the issue in Nop Commerce frame work. We have tested and verified the issue in Edit/Update functionality in Product Attribute List (Grid). Try to avoid the adding <br> html element with the attribute default value, better to use <span> with fixed width then we can avoid this issue.

For more info,


1)  The property named “ValidationRulesString” in Nop.Admin.Models.Catalog.ProductAttributeMappingModel is not allowing HTML encoded Data.This field needs to have [AllowHtml] Attribute Directive in order to accept HTML encoded data.

2)  The Action Method named “ProductAttributeMappingList” in Nop.Admin.Controllers. ProductController  sets the ValidationRulesString property with <br> tag.

Please find the Code snippet :

                 if (x.ValidationRulesAllowed())
                    {
                        var validationRules = new StringBuilder(string.Empty);
                        attributeModel.ValidationRulesAllowed = true;
                        if (x.ValidationMinLength != null)
                            validationRules.AppendFormat("{0}: {1}<br />"
                            ValidationRules.MinLength"),
                                x.ValidationMinLength);
                        if (x.ValidationMaxLength != null)
                            validationRules.AppendFormat("{0}: {1}<br />",
                              ValidationRules.MaxLength"),
                                x.ValidationMaxLength);
                        if (!string.IsNullOrEmpty(x.ValidationFileAllowedExtensions))
                            validationRules.AppendFormat("{0}: {1}<br />",
                              ValidationRules.FileAllowedExtensions"),
                                HttpUtility.HtmlEncode(x.ValidationFileAllowedExtensions));
                        if (x.ValidationFileMaximumSize != null)
                            validationRules.AppendFormat("{0}: {1}<br />"
                  
                  attributeModel.ValidationRulesString = validationRules.ToString();



3)  Either the ProductAttributeMappingModel should have “ [AllowHtml] “ decorated to the property named “ValidationRulesString “ or the Action Method named “ProductAttributeMappingUpdate()” must be decorated with “ [ValidateInput(false)] “ in Nop.Admin.Controllers. ProductController.


I tried to remove <br/> tag using Jquery from Client side but it wont work as the ValidationRulesString wont be affected by the JQuery script.So from my analysis, we need to change the NOP Model or Controller to accept the HTML encoded Data.


I tried with the Demo site of NOP Commerce  “http://admin-demo.nopcommerce.com/”.The same error exist there.So the NopCommerce Team needs to take care of this issue.
6 years ago
Thanks a lot! This issue is fixed automatically in the upcoming version 4.00 (where such validation is disabled out of the box)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.