From e96ad4fd5e2058c80c500b0e50ad134710daebd4 Mon Sep 17 00:00:00 2001 From: Danilo Ramirez Date: Fri, 22 Oct 2021 14:42:03 +1100 Subject: [PATCH] Create EscapeSingleQuote in utils --- internal/utils/odata_query_string.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 internal/utils/odata_query_string.go diff --git a/internal/utils/odata_query_string.go b/internal/utils/odata_query_string.go new file mode 100644 index 0000000000..2024f94d11 --- /dev/null +++ b/internal/utils/odata_query_string.go @@ -0,0 +1,11 @@ +package utils + +import "strings" + +// 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, `'`, `''`) +}