Skip to content

Commit

Permalink
odata: add helper function for escaping single quotes in OData query …
Browse files Browse the repository at this point in the history
…paramater values
  • Loading branch information
manicminer committed Oct 17, 2023
1 parent 4b3fb7c commit 220ed2e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdk/odata/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,11 @@ func (o OrderBy) String() (val string) {
}
return
}

// EscapeSingleQuote replaces all occurrences of single quote, with 2 single quotes.
// For requests that use single quotes, if any parameter values also contain single quotes,
// those must be double escaped; otherwise, the request will fail due to invalid syntax.
// https://docs.microsoft.com/en-us/graph/query-parameters#escaping-single-quotes
func EscapeSingleQuote(qparam string) string {
return strings.ReplaceAll(qparam, `'`, `''`)
}

0 comments on commit 220ed2e

Please sign in to comment.