Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions Ellucian.Ethos.Integration/Client/Proxy/EthosFilterQueryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,35 +1483,38 @@ protected Pager PreparePagerForPageSize( Pager pager )
/// <summary>
/// <b>Used internally by the SDK.</b>
/// <p>
/// 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.</p>
/// <p>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.</p>
/// <p>Returns a criteria filter string that begins with the ?...=, with the JSON filter portion of the string
/// encoded. Uses UTF-8 encoding.</p>
/// </summary>
/// <param name="criteriaFilterStr">The criteria filter string to encode.</param>
/// <returns>A criteria filter string beginning with the CRITERIA_FILTER_PREFIX with the JSON filter syntax portion of the
/// <returns>A filter string with the JSON filter syntax portion of the
/// string encoded in UTF-8.</returns>
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));
}

/// <summary>
Expand Down