Skip to content

Commit

Permalink
Consume EscapeSingleQuote in user(s) data source
Browse files Browse the repository at this point in the history
  • Loading branch information
daramir committed Nov 4, 2021
1 parent e96ad4f commit 33a08fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/services/users/user_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion internal/services/users/users_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 33a08fd

Please sign in to comment.