From 21c7edb3db6e715c60858b4bd5afe55556b388e9 Mon Sep 17 00:00:00 2001 From: Danilo Ramirez Date: Fri, 22 Oct 2021 14:42:58 +1100 Subject: [PATCH] Consume EscapeSingleQuote in user(s) data source --- internal/services/users/user_data_source.go | 3 ++- internal/services/users/users_data_source.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/services/users/user_data_source.go b/internal/services/users/user_data_source.go index 54c9b3b188..3e2ed8840f 100644 --- a/internal/services/users/user_data_source.go +++ b/internal/services/users/user_data_source.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/tf" + "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -316,7 +317,7 @@ func userDataSourceRead(ctx context.Context, d *schema.ResourceData, meta interf if upn, ok := d.Get("user_principal_name").(string); ok && upn != "" { query := odata.Query{ - Filter: fmt.Sprintf("userPrincipalName eq '%s'", upn), + Filter: fmt.Sprintf("userPrincipalName eq '%s'", utils.EscapeSingleQuote(upn)), } users, _, err := client.List(ctx, query) if err != nil { diff --git a/internal/services/users/users_data_source.go b/internal/services/users/users_data_source.go index d0a4169880..fee72eff0e 100644 --- a/internal/services/users/users_data_source.go +++ b/internal/services/users/users_data_source.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/tf" + "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -179,7 +180,7 @@ func usersDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter expectedCount = len(upns) for _, v := range upns { query := odata.Query{ - Filter: fmt.Sprintf("userPrincipalName eq '%s'", v), + Filter: fmt.Sprintf("userPrincipalName eq '%s'", utils.EscapeSingleQuote(v.(string))), } result, _, err := client.List(ctx, query) if err != nil {