Skip to content

Commit 6f68268

Browse files
authored
Merge pull request #44 from zfi/1.1.4
Add template variables to suplement plus sign in some email addresses
2 parents d77065c + 8e9b6b2 commit 6f68268

File tree

12 files changed

+93
-32
lines changed

12 files changed

+93
-32
lines changed

app/Email/services.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@ def send_email_template_to_address(recipient, template, server, locale, params=N
9999
params['email'] = recipient
100100
params['locale'] = locale
101101

102+
# Create a URI-friendly version of the email addresses
103+
params['email-uri'] = _convert_email_uri(params['email'])
104+
logging.info("Email address %s converted to %s",
105+
params['email'],
106+
params['email-uri']
107+
)
108+
109+
params['registrant-email-uri'] = _convert_email_uri(params['registrant-email'])
110+
logging.info("Registrant email address %s converted to %s",
111+
params['registrant-email'],
112+
params['registrant-email-uri']
113+
)
114+
115+
params['sponsor-email-uri'] = _convert_email_uri(params['sponsoremail'])
116+
logging.info("Sponsor email address %s converted to %s",
117+
params['sponsoremail'],
118+
params['sponsor-email-uri']
119+
)
120+
102121
# Read templates
103122
(subject, plain, rich) = _read_templates(template, server, locale, params)
104123
# Add error checking here to detect any issues with parsing the template.
@@ -180,3 +199,19 @@ def _read_template(template, server, locale, part, params, none_if_missing=False
180199
return None
181200
else:
182201
return 'Template missing'
202+
203+
204+
def _convert_email_uri(email):
205+
"""
206+
Evaluate email address and replace any plus signs that may appear in the
207+
portion of the address prior to the '@' with the literal '%2B'.
208+
209+
Standard web servers will convert any plus ('+') symbol to a space (' ')
210+
anywhere where they may appear in the URL. This will allow functions upstream
211+
to create a URI that contains an email address that, when submitted to a
212+
server, will not be replaced with a space character.
213+
"""
214+
if "+" in email:
215+
return email.replace("+", "%2B")
216+
else:
217+
return email

app/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
app = Flask(__name__)
2525

2626
# Application version (major,minor,patch-level)
27-
version = "1.1.3"
27+
version = "1.1.4"
2828

2929
"""
3030
Change Log
3131
32+
1.1.4 Add code to convert plus signs located the the username portion
33+
of an email address to a '%2B'when the email address is embedded
34+
in a URL.
35+
3236
1.1.3 Added documentation around the user account registration process.
3337
3438
"""

templates/en/confirm-parent/blocklyprop/plain.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ Getting Started with BlocklyProp for more information.
3737

3838
Confirm account registration:
3939
Copy and paste into your browser
40-
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email}}&token={{token}} to confirm your email address.
41-
42-
If the above link is unable to complete your registration, please go to
43-
http://{{blocklyprop-host}}/blockly/confirm and enter your email address and the token: {{token}}
40+
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
4441

4542
If the above link is unable to complete the registration, please go to
4643
http://{{blocklyprop-host}}/blockly/confirm and enter your email address and the token: {{token}}

templates/en/confirm-teacher/blocklyprop/plain.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ If this is your student, please confirm the registration by copying the link bel
1212
your browser or by navigating to the second link and confirming the student's email address.
1313

1414
Copy and paste into your browser
15-
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email}}&token={{token}} to confirm your email address.
15+
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
1616

1717
If the above link is unable to complete your registration, please go to
18-
http://{{blocklyprop-host}}/blockly/confirm and enter your student's email address ({{registrant-email}}) and the token: {{token}}
18+
http://{{blocklyprop-host}}/blockly/confirm and enter your student's email address ({{registrant-email-uri}}) and the token: {{token}}
1919

2020
Regards,
2121

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{! This is the text body of the email}}
22
Dear {{screenname}},
33

4-
Please go to http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email}}&token={{token}} to confirm your email address.
4+
Please go to http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
55

6-
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/confirm, then enter your email address ({{email}}), and the supplied token: {{token}}
6+
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/confirm, then enter your email address ({{email-uri}}), and the supplied token: {{token}}
77

88

99
The Parallax team

templates/en/reset-coppa/blocklyprop/plain.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Hello,
66

77
The BlocklyProp web site has received a request to reset the password for user '{{screenname}}'.
88

9-
If this request was made by you, please go to http://{{blocklyprop-host}}/blockly/reset?locale={{locale}}&email={{registrant-email}}&token={{token}} to reset your password now.
9+
If this request was made by you, please go to http://{{blocklyprop-host}}/blockly/reset?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to reset your password now.
1010

1111
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/reset and use the token: {{token}}
1212

templates/en/reset/blocklyprop/plain.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Hello,
22

33
The BlocklyProp web site has received a request to reset the password for user '{{screenname}}'.
44

5-
If this request was made by you, please go to http://{{blocklyprop-host}}/blockly/reset?locale={{locale}}&email={{registrant-email}}&token={{token}} to reset your password now.
5+
If this request was made by you, please go to http://{{blocklyprop-host}}/blockly/reset?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to reset your password now.
66

77
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/reset and use the token: {{token}}
88

templates/en_US/confirm-parent/blocklyprop/plain.mustache

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,45 @@
1111
}}
1212
Hello,
1313

14-
A person under age 13 has requested a new account on the Parallax BlocklyProp web site http://{{blocklyprop-host}} under the screen name {{screenname}}. In the request, your email address was provided as the parent or guardian of the requester.
15-
16-
BlocklyProp is a free, online programming tool designed for education. See Getting Started with BlocklyProp for more information.
17-
18-
Why are we sending this? In the US, the federal Children's Online Privacy Protection Act (COPPA) requires that we communicate with a parent or guardian of any person under age 13 that requests a BlocklyProp account. A full copy of our Child Privacy Policy is available online at: http://{{blocklyprop-host}}/blockly/privacy-policy
19-
20-
To complete your child's account registration, please copy and past this link into your browser to confirm your email address:
21-
22-
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email}}&token={{token}} to confirm your email address.
23-
24-
If the above link is unable to complete the registration, please go to http://{{blocklyprop-host}}/blockly/confirm and enter your email address and the token: {{token}}
25-
26-
If you do NOT want to complete your child's account registration, you need do nothing more; this confirmation request will automatically expire in 7 days and the account will not be created.
27-
28-
If you do complete your child's account registration, you may close the account in the future. Email a request for closure and your child's screen name to blocklyadmin@parallax.com. We will confirm your request and then close the account and remove any projects that are associated with the account.
14+
Someone, perhaps your child, has requested a new account on the Parallax
15+
BlocklyProp web site (http://blockly.parallax.com) under the screen name
16+
{{screenname}}. When the account was created, your email address was
17+
submitted as the parent or guardian of the registrant. If this is incorrect,
18+
please accept our apologies. There is nothing more you need to do. The
19+
request will automatically expire.
20+
21+
Why are we sending this? In the US, the federal Children's Online Privacy
22+
Protection Act, known as COPPA, requires that we communicate with a parent
23+
or guardian if the person registering an BlocklyProp account is under the
24+
age of 13. The Act allows you to decline the registration request. If you
25+
choose this option, we will immediately remove the registration information
26+
and the associated account. If you choose to confirm the the request and
27+
activate the account, you may close the account at any time by clicking on
28+
the link provided below. This action will close the account and remove any
29+
projects that are associated with the account.
30+
31+
A full copy of our Child Privacy Policy is available online at:
32+
http://{{blocklyprop-host}}/blockly/child-privacy-policy
33+
34+
BlocklyProp is a free, online programming tool designed for education. See
35+
Getting Started with BlocklyProp for more information.
36+
37+
38+
Confirm account registration:
39+
Copy and paste into your browser
40+
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
41+
42+
If the above link is unable to complete the registration, please go to
43+
http://{{blocklyprop-host}}/blockly/confirm and enter your email address and the token: {{token}}
44+
45+
If you do NOT want to complete your child's account registration, you need do
46+
nothing more; this confirmation request will automatically expire in 7 days and
47+
the account will not be created.
48+
49+
If you do complete your child's account registration, you may close the account
50+
in the future. Email a request for closure and your child's screen name to
51+
blocklyadmin@parallax.com. We will confirm your request and then close the account
52+
and remove any projects that are associated with the account.
2953

3054
Regards,
3155

templates/en_US/confirm-teacher/blocklyprop/plain.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ If this is your student, please confirm the registration by copying the link bel
1212
your browser or by navigating to the second link and confirming the student's email address.
1313

1414
Copy and paste into your browser
15-
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email}}&token={{token}} to confirm your email address.
15+
http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
1616

1717
If the above link is unable to complete your registration, please go to
18-
http://{{blocklyprop-host}}/blockly/confirm and enter your student's email address ({{registrant-email}}) and the token: {{token}}
18+
http://{{blocklyprop-host}}/blockly/confirm and enter your student's email address ({{registrant-email-uri}}) and the token: {{token}}
1919

2020
Regards,
2121

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{{! This is the text body of the email}}
22
Dear {{screenname}},
33

4-
Please go to http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{email}}&token={{token}} to confirm your email address.
4+
Please go to http://{{blocklyprop-host}}/blockly/confirm?locale={{locale}}&email={{registrant-email-uri}}&token={{token}} to confirm your email address.
5+
6+
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/confirm, then enter your email address ({{email-uri}}), and the supplied token: {{token}}
57

6-
If the url does not work, please go to http://{{blocklyprop-host}}/blockly/confirm and enter your email address and the supplied token: {{token}}
78

89
The Parallax team

0 commit comments

Comments
 (0)