diff --git a/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs b/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs index d28d933..3c1d173 100644 --- a/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs +++ b/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs @@ -1483,35 +1483,38 @@ protected Pager PreparePagerForPageSize( Pager pager ) /// /// Used internally by the SDK. ///

- /// Encodes the given criteriaFilterStr. Supports criteria filter strings that begin with the CRITERIA_FILTER_PREFIX - /// value "?criteria=", and also those that do not. Encodes only the JSON criteria portion of the filter string, removing - /// the CRITERIA_FILTER_PREFIX portion if the filter string starts with it. If the filter string does not start with - /// the CRITERIA_FILTER_PREFIX, the criteriaFilterStr string is simply encoded.

- ///

Returns a criteria filter string that begins with the CRITERIA_FILTER_PREFIX, with the JSON filter portion of the string + /// Encodes the given criteriaFilterStr. Supports criteria filter strings that begin with a ?...= section where + /// ... is criteria, personFilter, accountSpecification, etc ("?criteria="). Encodes only the JSON criteria portion of the filter string, leaving + /// the beginning section alone. If the filter string does not start with ?...=, the criteriaFilterStr string is simply encoded.

+ ///

Returns a criteria filter string that begins with the ?...=, with the JSON filter portion of the string /// encoded. Uses UTF-8 encoding.

///
/// The criteria filter string to encode. - /// A criteria filter string beginning with the CRITERIA_FILTER_PREFIX with the JSON filter syntax portion of the + /// A filter string with the JSON filter syntax portion of the /// string encoded in UTF-8. private static string EncodeString( string criteriaFilterStr ) { + char eq = '='; StringBuilder sb = new StringBuilder(); string jsonCriteriaStr; - bool isNamedQuery = false; - if ( criteriaFilterStr.StartsWith( CRITERIA_FILTER_PREFIX ) ) - { - // It starts with "?criteria=", so substring the rest of the filter and encode it. - jsonCriteriaStr = criteriaFilterStr [ ( criteriaFilterStr.IndexOf( "=" ) + 1 ).. ]; - } - else - { - jsonCriteriaStr = criteriaFilterStr; - isNamedQuery = true; + string notJsonCriteriaStr; + + /// It starts with "?" and contains "=", so substring the rest of the filter and encode it. + if (criteriaFilterStr.Contains(eq) && criteriaFilterStr.StartsWith('?')) { + /// everything before the first equals sign + notJsonCriteriaStr = criteriaFilterStr[..(criteriaFilterStr.IndexOf(eq) + 1)]; + /// everything after the first equals sign + jsonCriteriaStr = criteriaFilterStr[(criteriaFilterStr.IndexOf(eq) + 1)..]; + + /// don't encode the first section of the qstring + sb.Append(notJsonCriteriaStr); + /// encode the rest + sb.Append(System.Web.HttpUtility.UrlEncode(jsonCriteriaStr, Encoding.UTF8)); + + return sb.ToString(); } - jsonCriteriaStr = System.Web.HttpUtility.UrlEncode( jsonCriteriaStr, Encoding.UTF8 ); - if ( !isNamedQuery ) sb.Append( CRITERIA_FILTER_PREFIX ); - sb.Append( jsonCriteriaStr ); - return sb.ToString(); + /// doesn't contain ? or =, encode the whole thing? + return System.Web.HttpUtility.UrlEncode(criteriaFilterStr, Encoding.UTF8)); } ///