From 0372e1aefd943dbbaa66f6e6c28a3c14a68bbcb0 Mon Sep 17 00:00:00 2001 From: Cluggish Date: Fri, 4 Oct 2024 11:33:26 -0400 Subject: [PATCH 1/2] Update EthosFilterQueryClient.cs Update to EncodeString() to work with NamedQueryFilters --- .../Client/Proxy/EthosFilterQueryClient.cs | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) 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)); } /// From 629c52580cc6a9f4b5b14bd27ae6efa50fc6317f Mon Sep 17 00:00:00 2001 From: Cluggish Date: Tue, 5 May 2026 13:33:00 -0400 Subject: [PATCH 2/2] Fix syntax error in UrlEncode method call --- .../Client/Proxy/EthosFilterQueryClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs b/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs index 3c1d173..09ddeab 100644 --- a/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs +++ b/Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs @@ -1514,7 +1514,7 @@ private static string EncodeString( string criteriaFilterStr ) return sb.ToString(); } /// doesn't contain ? or =, encode the whole thing? - return System.Web.HttpUtility.UrlEncode(criteriaFilterStr, Encoding.UTF8)); + return System.Web.HttpUtility.UrlEncode(criteriaFilterStr, Encoding.UTF8); } ///