Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter is incorrectly handling special characters #2973

Closed
gavinbarron opened this issue Sep 27, 2024 · 1 comment · Fixed by #2999
Closed

Filter is incorrectly handling special characters #2973

gavinbarron opened this issue Sep 27, 2024 · 1 comment · Fixed by #2999
Assignees
Labels
type:bug A broken experience

Comments

@gavinbarron
Copy link
Member

gavinbarron commented Sep 27, 2024

Describe the bug

When attempting to use a + symbol in a filter string the resulting query is not correctly encoded

Expected behavior

  • symbol is encoded as %2B in the request made against graph

How to reproduce

  1. run Get-MgUser -Filter "onPremisesImmutableId in ('AegKW3DO+Uin3xHz7t0pIw==', 'YQuy6DbntUCGREZeTT5YwA==')" -Debug
  2. See that the request made contains a space in the value supplied as the $filter query parameter.
HTTP Method:
GET

Absolute Uri:
https://graph.microsoft.com/v1.0/users?$filter=onPremisesImmutableId in %28%27AegKW3DO Uin3xHz7t0pIw%3D%3D%27%2C %27YQuy6DbntUCGREZeTT5YwA%3D%3D%27%29

SDK Version

2.23.0

Latest version known to work for scenario above?

No response

Known Workarounds

Invoke-MgRestMethod -Uri 'https://graph.microsoft.com/v1.0/users?$filter=onPremisesImmutableId%20in%20%28%27AegKW3DO%2BUin3xHz7t0pIw%3D%3D%27%2C%20%27YQuy6DbntUCGREZeTT5YwA%3D%3D%27%29' -Debug

results in the correct encoding of the URL parameters:

DEBUG: GET /v1.0/users?$filter=onPremisesImmutableId%20in%20%28%27AegKW3DO%2BUin3xHz7t0pIw%3D%3D%27%2C%20%27YQuy6DbntUCGREZeTT5YwA%3D%3D%27%29 HTTP/1.1
HTTP: graph.microsoft.com

Debug output

Click to expand log
DEBUG: [CmdletBeginProcessing]: - Get-MgUser begin processing with parameterSet 'List'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'DeviceCode', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, AuditLog.Read.All, Calendars.ReadWrite, openid, profile, User.Read, User.Read.All, User.ReadWrite, email].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://graph.microsoft.com/v1.0/users?$filter=onPremisesImmutableId in %28%27AegKW3DO Uin3xHz7t0pIw%3D%3D%27%2C %27YQuy6DbntUCGREZeTT5YwA%3D%3D%27%29

Headers:
FeatureFlag                   : 00000043
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.26100; en-US),PowerShell/7.4.5
Accept-Encoding               : gzip
SdkVersion                    : graph-powershell/2.23.0
client-request-id             : cab71d36-315b-4ddc-ac84-e62dd819d10b

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : ff1f401e-48c6-4226-bdf3-06508749b56e
client-request-id             : cab71d36-315b-4ddc-ac84-e62dd819d10b
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"West US 2","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"CO1PEPF00004BE8"}}
x-ms-resource-unit            : 2
OData-Version                 : 4.0
Date                          : Fri, 27 Sep 2024 20:48:23 GMT

Body:
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
  "value": []
}


DEBUG: [CmdletEndProcessing]: - Get-MgUser end processing.

Configuration

PS C:\Users\gavinbarron> $PSVersionTable

Name Value


PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Other information

This issue is being tracked as an IcM id=544584306

@timayabi2020
Copy link
Contributor

Solution provided for #2280 needs to be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
2 participants