1
Vote

Can't handle properties with non-ASCII characters

description

The property bag settings can't handle characters that essentially is breaking the URL since it's used in a querystring when modifying and deleting a propertybag setting.

This is easily fixed by adding HttpUtility.UrlEncode in the places where the key is added to the querystring and then use HttpUtility.UrlDecode where it is later fetched.

Example in PropertyBag.aspx.cs:
sb.Append(String.Format(MOD_PROP, property.Key.ToString(), "edt", scope, guid, web, site));

Change to this:
sb.Append(String.Format(MOD_PROP, HttpUtility.UrlEncode(property.Key.ToString()), "edt", scope, guid, web, site));

And then in ModifyPropertyBag.aspx.cs:
        if (Request.QueryString[QS_KEY] != null)
        {
            key = Request.QueryString[QS_KEY];
        }
Change to:
        if (Request.QueryString[QS_KEY] != null)
        {
            key = HttpUtility.UrlDecode(Request.QueryString[QS_KEY]);
        }

This needs to be done in both ADMIN files and in the Layouts files to handle when using the propertybag in admin or non-admin mode.

Thanks for a nice utility!

Regards
Anders

comments