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

Fix/email format #41

Merged
merged 10 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
decidim-friendly_signup (0.4.5)
decidim-friendly_signup (0.4.6)
decidim-core (~> 0.27)

GEM
Expand Down Expand Up @@ -796,6 +796,7 @@ GEM
PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-20
x86_64-linux

Expand All @@ -818,4 +819,4 @@ RUBY VERSION
ruby 3.0.2p107

BUNDLED WITH
2.4.9
2.5.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Decidim
module FriendlySignup
class RegistrationFormOverride < Decidim::RegistrationForm
validate :no_special_characters_in_email

private

EMAIL_REGEX = /\A[^<>"']+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,}/

def no_special_characters_in_email
errors.add(:email, :invalid) if email =~ EMAIL_REGEX
end
end
end
end
2 changes: 1 addition & 1 deletion lib/decidim/friendly_signup/version.rb
Copy link
Contributor

Choose a reason for hiding this comment

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

For the future, we will need to find a way to make it "automatic" so we don't have to change it on every pull request but for now it's good !

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module Decidim
module FriendlySignup
DECIDIM_VERSION = "0.27.4"
COMPAT_DECIDIM_VERSION = "~> 0.27"
VERSION = "0.4.5"
VERSION = "0.4.6"
end
end
12 changes: 12 additions & 0 deletions spec/forms/registration_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,17 @@ module Decidim
end
end
end

context "when email contains a script tag" do
let(:email) { "<script>alert('XSS')</script>@example.org" }

it { is_expected.to be_invalid }

context "when email contains invalid characters" do
let(:email) { 'user"@example.org' }

it { is_expected.to be_invalid }
end
end
end
end
Loading