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

normalized input of parseStringOrThrowError method #830

Merged
merged 18 commits into from
Oct 15, 2023
Merged

normalized input of parseStringOrThrowError method #830

merged 18 commits into from
Oct 15, 2023

Conversation

Taz03
Copy link

@Taz03 Taz03 commented Oct 7, 2023

Related issues

fixes #594

Checklist for important updates

  • Changelog has been updated
    • If there are any db schema changes, mention those changes clearly
  • coreDriverInterfaceSupported.json file has been updated (if needed)
  • pluginInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In build.gradle
  • If added a new paid feature, edit the getPaidFeatureStats function in FeatureFlag.java file
  • Had installed and ran the pre-commit hook
  • If there are new dependencies that have been added in build.gradle, please make sure to add them
    in implementationDependencies.json.
  • Update function getValidFields in io/supertokens/config/CoreConfig.java if new aliases were added for any core config (similar to the access_token_signing_key_update_interval config alias).
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the
      latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If added a foreign key constraint on app_id_to_user_id table, make sure to delete from this table when deleting the user as well if deleteUserIdMappingToo is false.

return ((JsonObject) element).get(fieldName).getAsString();
String s = element.get(fieldName).getAsString().trim();

if (s.matches("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We use the following regex in our backend SDK: https://github.com/supertokens/supertokens-node/blob/master/lib/ts/recipe/emailpassword/utils.ts#L242.

Might want to make this consistent with that.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -137,7 +137,12 @@ public static String parseStringOrThrowError(JsonObject element, String fieldNam
if (!stringified.contains("\"")) {
throw new Exception();
}
return ((JsonObject) element).get(fieldName).getAsString();
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is called for non GET request. We might want to add the trim and toLowerCase (in case of email), to the GET request equivalent as well. The functions are getQueryParamOrThrowError and getCommaSeparatedStringArrayQueryParamOrThrowError

Copy link
Author

Choose a reason for hiding this comment

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

Done

@Taz03 Taz03 requested a review from rishabhpoddar October 11, 2023 08:09
@rishabhpoddar rishabhpoddar changed the base branch from 7.0 to email-auto-normalise October 15, 2023 14:11
@rishabhpoddar rishabhpoddar merged commit e20380e into supertokens:email-auto-normalise Oct 15, 2023
0 of 2 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.

2 participants