Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: Unescape(Escape()) does not return the original string in go/sqlescape #14992

Closed
Maniktherana opened this issue Jan 19, 2024 · 2 comments · Fixed by #15009
Closed

Comments

@Maniktherana
Copy link
Contributor

Overview of the Issue

EscapeID for the string a`a returns `a``a` but UnescapeID doesn't reverse it. Currently, it simply returns a``a, removing the outer backticks without halving the ones inside the string.

related: #14987

Reproduction Steps

run this code:

package main

import (
	"fmt"

	"vitess.io/vitess/go/sqlescape"
)

func main() {
	str := "a`a"
	escaped := sqlescape.EscapeID(str)
	unescaped := sqlescape.UnescapeID(escaped)
	unescaped2 := sqlescape.UnescapeID("`a`a`")
	fmt.Printf("String: %s\nEscaped: %s\nUnescaped: %s\nUnescaped2: %s", str, escaped, unescaped, unescaped2)
}

output should be:

String: a`a
Escaped: `a``a`
Unescaped: a``a
Unescaped2: a`a

Binary Version

vtgate version Version: 18.0.3-SNAPSHOT

Operating System and Environment details

- Operating system macOS 14.0
- Kernel version Darwin 23.0.0
- Architecture arm64

Log Fragments

No response

@Maniktherana Maniktherana added Needs Triage This issue needs to be correctly labelled and triaged Type: Bug labels Jan 19, 2024
@Maniktherana
Copy link
Contributor Author

If this is a bug, I'd be happy to patch it while working on tests for go/sqlescape

@ajm188 ajm188 added Component: Query Serving and removed Needs Triage This issue needs to be correctly labelled and triaged labels Jan 19, 2024
@systay
Copy link
Collaborator

systay commented Jan 19, 2024

this looks like a real bug. thanks for taking it on!

if possible, make the bug fix into a separate PR. That makes it much easier to back port the fix to earlier releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants