Skip to content

comment detection doesn't check if -- is in a string #1

@mike-weinberg

Description

@mike-weinberg

string = re.sub(re.compile("--.*?\n", re.DOTALL ) ,"" ,string) # remove all occurance streamed comments (/*COMMENT */) from string

an adversarial example would be

>>> string = """
SELECT SPLIT_PART(text_with_double_hyphen_delimiter, '--', 1) 
FROM table_with_weird_text
"""
>>> remove_comments(string)
"SELECT SPLIT_PART(text_with_double_hyphen_delimiter, 'FROM table_with_weird_text"

I think you need to truly tokenize the query to not hit this edge case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions