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

[REF-3016]Allow special characters in upload ID #3449

Merged
merged 8 commits into from
Jun 12, 2024

Conversation

ElijahAhianyo
Copy link
Collaborator

@ElijahAhianyo ElijahAhianyo commented Jun 6, 2024

We should allow special characters as upload id for the following:

rx.upload(..., id=<upload_id>),
rx.selected_files(<upload_id>)
rx.upload_files(upload_id=<upload_id>)
rx.clear_selected_files(<upload_id>)

fixes #3444

Copy link

linear bot commented Jun 6, 2024

@ElijahAhianyo ElijahAhianyo marked this pull request as ready for review June 6, 2024 13:13
@ElijahAhianyo ElijahAhianyo marked this pull request as draft June 6, 2024 13:22
@ElijahAhianyo ElijahAhianyo changed the title [REF-3016]Disallow special characters in upload ID [REF-3016]Allow special characters in upload ID Jun 6, 2024
@ElijahAhianyo ElijahAhianyo marked this pull request as ready for review June 6, 2024 17:00
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we still have a problem when the id contains the backtick character...

>>> import reflex.components.core.upload as upl
>>> print(str(upl.upload_file("foo`bar")))
{e => setFilesById(filesById => {
    const updatedFilesById = Object.assign({}, filesById);
    updatedFilesById[`foo`bar`] = e;
    return updatedFilesById;
  })
    }

If we convert the id_ to a Var with _var_is_string=True, and then get the _var_name_unwrapped, then it provides the outer backticks automatically and escapes the inner backtick(s)

>>> import reflex as rx
>>> rx.Var.create_safe("foo`bar", _var_is_string=True)._var_name_unwrapped
'`foo\\`bar`'

@picklelo picklelo merged commit 8c8156f into main Jun 12, 2024
47 checks passed
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

Successfully merging this pull request may close these issues.

[REF-3016] Upload ID should allow characters
3 participants