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

Quote escaping issues leads to lost backslash \ and syntax errors #141

Open
darist opened this issue Feb 4, 2023 · 0 comments
Open

Quote escaping issues leads to lost backslash \ and syntax errors #141

darist opened this issue Feb 4, 2023 · 0 comments

Comments

@darist
Copy link

darist commented Feb 4, 2023

Hi there, I ran into this situation:

Given yaml like:

arguments:
    - --textproto_content
    - 'query: "\''foo\'' = \"foo\"" x: "bar"'

Boundary layer produces Python code like (whitespace added for clarity):

arguments = [
          '--textproto_content',
          """query: "\'foo\' = \"foo\"" x: "bar"""",

There are two problems with the generated """query:... code above:

  • The string ending with 4 " characters: """" causes a syntax error
>>> print("""query: "\'foo\' = \"foo\"" x: "bar"""")
  File "<stdin>", line 1
    print("""query: "\'foo\' = \"foo\"" x: "bar"""")
                                                  ^
SyntaxError: unterminated string literal (detected at line 1)
  • Even if I fix that syntax error, we lose the \ characters that were part of the original string (and we need so that the resulting string that is passed to the operator is valid textproto)
>>> print("""query: "\'foo\' = \"foo\"" x: "bar" """)
query: "'foo' = "foo"" x: "bar" 

Expected:

query: "\'foo\' = \"foo\"" x: "bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant