public static void EncodeProperties(object argumentValue) { var propertiesFlaggedForSanitization = argumentValue.GetType().GetProperties().Where(e => e.PropertyType == typeof(string) && e.GetCustomAttribute <ExcludeSanitizationAttribute>() == null).ToList(); if (propertiesFlaggedForSanitization.Any()) { foreach (var propertyInfo in propertiesFlaggedForSanitization) { var raw = (string)propertyInfo.GetValue(argumentValue); if (!string.IsNullOrEmpty(raw)) { propertyInfo.SetValue(argumentValue, AntiXssEncoder.HtmlEncode(raw, true)); } } } }
private static string UrlEncode(string s) { return(Encoder.UrlEncode(s)); }
private string AddWebsitePathToQuerystring(string uri) { var portalContext = PortalCrmConfigurationManager.CreatePortalContext(PortalName); var website = portalContext.Website; if (website != null) { var partialUrl = website.GetAttributeValue <string>("adx_partialurl"); if (!string.IsNullOrWhiteSpace(partialUrl)) { return("{0}{1}websitepath={2}".FormatWith(uri, uri.Contains("?") ? "&" : "?", Encoder.UrlEncode(partialUrl))); } } return(uri); }