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

tsdb.unescape() is too naive with escaped slashes #257

Closed
goodmami opened this issue Nov 27, 2019 · 0 comments
Closed

tsdb.unescape() is too naive with escaped slashes #257

goodmami opened this issue Nov 27, 2019 · 0 comments
Labels

Comments

@goodmami
Copy link
Member

I encountered this bug while doing type checks, not with actual data, but then again it wouldn't trigger an error so it may have just not been noticed.

I recently replaced the regex-based substitution to escape and unescape TSDB strings with simple str.replace() calls, which were about 3-4 time faster. This works well enough for escaping, but for unescaping it causes issues because of the multiple calls. Specifically, an escaped \ followed by a regular s or n would look like an escaped \s or \n:

\\s    replace \\ with \
\s     replace \s with @
@

Switching the order of the replaces wouldn't help, because \\s would become \@ instead of \s. Instead, unescaping needs to return to some sequential low-level parser. Maybe a simple for-loop with if-statements will not be as slow as re.sub().

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

No branches or pull requests

1 participant