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

CSV export Characters Starting with @ #23967

Closed
steliosph opened this issue May 8, 2023 · 3 comments
Closed

CSV export Characters Starting with @ #23967

steliosph opened this issue May 8, 2023 · 3 comments
Labels
#bug Bug report

Comments

@steliosph
Copy link

When downloading any data that are starting with @ superset will automatically add the '

image

This provides an extra complexity in order to process the data.
Would it be ideal to not included the ' and let the users handle the data as they are entered.

Superset v2.1.0

@steliosph steliosph added the #bug Bug report label May 8, 2023
@tirkarthi
Copy link
Contributor

Probably an effect of #13735 to prevent csv injection.

# This regex will match if the string starts with:
#
# 1. one of -, @, +, |, =, %
# 2. two double quotes immediately followed by one of -, @, +, |, =, %
# 3. one or more spaces immediately followed by one of -, @, +, |, =, %
#
problematic_chars_re = re.compile(r'^(?:"{2}|\s{1,})(?=[\-@+|=%])|^[\-@+|=%]')
def escape_value(value: str) -> str:
"""
Escapes a set of special characters.
http://georgemauer.net/2017/10/07/csv-injection.html
"""
needs_escaping = problematic_chars_re.match(value) is not None
is_negative_number = negative_number_re.match(value) is not None
if needs_escaping and not is_negative_number:
# Escape pipe to be extra safe as this
# can lead to remote code execution
value = value.replace("|", "\\|")
# Precede the line with a single quote. This prevents
# evaluation of commands and some spreadsheet software
# will hide this visually from the user. Many articles
# claim a preceding space will work here too, however,
# when uploading a csv file in Google sheets, a leading
# space was ignored and code was still evaluated.
value = "'" + value
return value

@rusackas
Copy link
Member

Is this still happening in 3.x?

@rusackas
Copy link
Member

Wasn't sure if this was happening in 3.x, and not sure if it's happening in 4.x. Closing this one as stale, but more than happy to reopen it if it's still happening in supported (4.x, currently) versions.

@rusackas rusackas closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

3 participants