Skip to content

Commit

Permalink
Escape attribute as identifier or string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
bersace committed May 14, 2024
1 parent 1c6abd2 commit d687d61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pages](https://github.com/dalibo/ldap2pg/pulls?utf8=%E2%9C%93&q=is%3Apr%20is%3Am
- Load .env file.
- Watch time spent inspecting Postgres.
- Log Postgres out of band warnings.
- Escape attribute with : `{sAMAccountName.identifier()}` and `{sAMAccountName.string()}`.



Expand Down
4 changes: 4 additions & 0 deletions internal/pyfmt/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (f Format) Format(values map[string]string) string {
v = strings.ToLower(v)
case "upper()":
v = strings.ToUpper(v)
case "identifier()":
v = fmt.Sprintf("\"%s\"", v)
case "string()":
v = fmt.Sprintf("'%s'", strings.ReplaceAll(v, "'", "''"))
default:
v = "!INVALID_METHOD"
}
Expand Down

0 comments on commit d687d61

Please sign in to comment.