From 4226b6d0e1bce12549320c40fe4669ff094d486c Mon Sep 17 00:00:00 2001 From: Chris Garcia Date: Fri, 28 Oct 2016 15:23:18 -0500 Subject: [PATCH 1/8] Corrected use of 'lowercase' and 'uppercase' to fix #1515 --- applications/admin/languages/nl.py | 4 ++-- applications/admin/languages/uk.py | 4 ++-- applications/admin/static/codemirror/keymap/vim.js | 6 +++--- gluon/tests/test_validators.py | 8 ++++---- gluon/validators.py | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/applications/admin/languages/nl.py b/applications/admin/languages/nl.py index 55d95be42..9998ee626 100755 --- a/applications/admin/languages/nl.py +++ b/applications/admin/languages/nl.py @@ -352,9 +352,9 @@ 'modules': 'modules', 'Multi User Mode': 'Multi User Mode', 'Must include at least %s %s': 'Moet ten minste bevatten %s %s', -'Must include at least %s lower case': 'Moet ten minste bevatten %s lower case', +'Must include at least %s lowercase': 'Moet ten minste bevatten %s kleine letter', 'Must include at least %s of the following : %s': 'Moet ten minste bevatten %s van het volgende : %s', -'Must include at least %s upper case': 'Moet ten minste bevatten %s upper case', +'Must include at least %s uppercase': 'Moet ten minste bevatten %s hoofdletter', 'new application "%s" created': 'nieuwe applicatie "%s" gemaakt', 'new application "%s" imported': 'new application "%s" imported', 'New Application Wizard': 'Nieuwe Applicatie Wizard', diff --git a/applications/admin/languages/uk.py b/applications/admin/languages/uk.py index a45124c65..e14628483 100755 --- a/applications/admin/languages/uk.py +++ b/applications/admin/languages/uk.py @@ -356,9 +356,9 @@ 'modules': 'модулі', 'Multi User Mode': 'Multi User Mode', 'Must include at least %s %s': 'Має вміщувати щонайменше %s %s', -'Must include at least %s lower case': 'Повинен включати щонайменше %s малих букв', +'Must include at least %s lowercase': 'Повинен включати щонайменше %s малих букв', 'Must include at least %s of the following : %s': 'Має включати не менше %s таких символів : %s', -'Must include at least %s upper case': 'Повинен включати щонайменше %s великих букв', +'Must include at least %s uppercase': 'Повинен включати щонайменше %s великих букв', 'new application "%s" created': 'новий додаток "%s" створено', 'new application "%s" imported': 'new application "%s" imported', 'New Application Wizard': 'Майстер створення нового додатку', diff --git a/applications/admin/static/codemirror/keymap/vim.js b/applications/admin/static/codemirror/keymap/vim.js index 682eb7a8c..a4c319107 100644 --- a/applications/admin/static/codemirror/keymap/vim.js +++ b/applications/admin/static/codemirror/keymap/vim.js @@ -314,8 +314,8 @@ // Vim does not support modifier only keys. return false; } - // TODO: Current bindings expect the character to be lower case, but - // it looks like vim key notation uses upper case. + // TODO: Current bindings expect the character to be lowercase, but + // it looks like vim key notation uses uppercase. if (isUpperCase(lastPiece)) { pieces[pieces.length - 1] = lastPiece.toLowerCase(); } @@ -3644,7 +3644,7 @@ * Extract the regular expression from the query and return a Regexp object. * Returns null if the query is blank. * If ignoreCase is passed in, the Regexp object will have the 'i' flag set. - * If smartCase is passed in, and the query contains upper case letters, + * If smartCase is passed in, and the query contains uppercase letters, * then ignoreCase is overridden, and the 'i' flag will not be set. * If the query contains the /i in the flag part of the regular expression, * then both ignoreCase and smartCase are ignored, and 'i' will be passed diff --git a/gluon/tests/test_validators.py b/gluon/tests/test_validators.py index c98b4c26e..49d4f9051 100644 --- a/gluon/tests/test_validators.py +++ b/gluon/tests/test_validators.py @@ -843,7 +843,7 @@ def test_IS_STRONG(self): '|'.join(['Minimum length is 8', 'Maximum length is 4', 'Must include at least 1 of the following: ~!@#$%^&*()_+-=?<>,.:;{}[]|', - 'Must include at least 1 upper case', + 'Must include at least 1 uppercase', 'Must include at least 1 number'])) ) rtn = IS_STRONG(es=True)('abcde') @@ -851,7 +851,7 @@ def test_IS_STRONG(self): ('abcde', '|'.join(['Minimum length is 8', 'Must include at least 1 of the following: ~!@#$%^&*()_+-=?<>,.:;{}[]|', - 'Must include at least 1 upper case', + 'Must include at least 1 uppercase', 'Must include at least 1 number'])) ) rtn = IS_STRONG(upper=0, lower=0, number=0, es=True)('Abcde1') @@ -859,8 +859,8 @@ def test_IS_STRONG(self): ('Abcde1', '|'.join(['Minimum length is 8', 'Must include at least 1 of the following: ~!@#$%^&*()_+-=?<>,.:;{}[]|', - 'May not include any upper case letters', - 'May not include any lower case letters', + 'May not include any uppercase letters', + 'May not include any lowercase letters', 'May not include any numbers'])) ) diff --git a/gluon/validators.py b/gluon/validators.py index 4181c2267..22ad1a75d 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -2470,7 +2470,7 @@ def __call__(self, value): class IS_LOWER(Validator): """ - Converts to lower case:: + Converts to lowercase:: >>> IS_LOWER()('ABC') ('abc', None) @@ -2485,7 +2485,7 @@ def __call__(self, value): class IS_UPPER(Validator): """ - Converts to upper case:: + Converts to uppercase:: >>> IS_UPPER()('abc') ('ABC', None) @@ -3025,22 +3025,22 @@ def __call__(self, value): all_upper = re.findall("[A-Z]", value) if self.upper > 0: if not len(all_upper) >= self.upper: - failures.append(translate("Must include at least %s upper case") + failures.append(translate("Must include at least %s uppercase") % str(self.upper)) else: if len(all_upper) > 0: failures.append( - translate("May not include any upper case letters")) + translate("May not include any uppercase letters")) if isinstance(self.lower, int): all_lower = re.findall("[a-z]", value) if self.lower > 0: if not len(all_lower) >= self.lower: - failures.append(translate("Must include at least %s lower case") + failures.append(translate("Must include at least %s lowercase") % str(self.lower)) else: if len(all_lower) > 0: failures.append( - translate("May not include any lower case letters")) + translate("May not include any lowercase letters")) if isinstance(self.number, int): all_number = re.findall("[0-9]", value) if self.number > 0: From 2d4817841f467f9a51f1b1af1fff2703b353b802 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Tue, 1 Nov 2016 11:31:01 +0100 Subject: [PATCH 2/8] Allow for firstname and lastname in verify_email message --- gluon/tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gluon/tools.py b/gluon/tools.py index eb4a61f92..db6a9840d 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -3417,7 +3417,9 @@ def register(self, link = self.url( self.settings.function, args=('verify_email', key), scheme=True) d = dict(form.vars) - d.update(dict(key=key, link=link, username=form.vars[username])) + d.update(dict(key=key, link=link, username=form.vars[username], + firstname=form.vars['firstname'], + lastname=form.vars['lastname'])) if not (self.settings.mailer and self.settings.mailer.send( to=form.vars.email, subject=self.messages.verify_email_subject, From 6b1225da029993b5231beaa83b86fa2b4b86702b Mon Sep 17 00:00:00 2001 From: Michele Comitini Date: Fri, 4 Nov 2016 09:59:49 +0100 Subject: [PATCH 3/8] keep the _next while doing the redirect --- gluon/tools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gluon/tools.py b/gluon/tools.py index eb4a61f92..db0c2e818 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -3670,7 +3670,12 @@ def confirm_registration(self, key = request.args[-1] if key: session._reset_password_key = key - redirect(self.url(args='confirm_registration')) + if next: + redirect_vars = {'_next': next} + else: + redirect_vars = {} + redirect(self.url(args='confirm_registration', + vars=redirect_vars)) else: key = session._reset_password_key else: @@ -7065,4 +7070,4 @@ def save(self, options): if __name__ == '__main__': import doctest - doctest.testmod() + doctest.testmod() \ No newline at end of file From c64a9192d49ee735981615a25ae2c5e9900f22ed Mon Sep 17 00:00:00 2001 From: Marvi Date: Fri, 11 Nov 2016 10:12:11 +0100 Subject: [PATCH 4/8] Update extract_mysql_models.py --- scripts/extract_mysql_models.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/extract_mysql_models.py b/scripts/extract_mysql_models.py index 4b4d4281f..dfaae02cf 100644 --- a/scripts/extract_mysql_models.py +++ b/scripts/extract_mysql_models.py @@ -18,7 +18,7 @@ If the script crashes this is might be due to that fact that the data_type_map dictionary below is incomplete. Please complete it, improve it and continue. -Created by Falko Krause, minor modifications by Massimo Di Pierro and Ron McOuat +Created by Falko Krause, minor modifications by Massimo Di Pierro, Ron McOuat and Marvi Benedet ''' import subprocess import re @@ -52,10 +52,11 @@ ) -def mysql(database_name, username, password): +def mysql(database_name, username, password, host): p = subprocess.Popen(['mysql', '--user=%s' % username, '--password=%s' % password, + '--host=%s' % host, '--execute=show tables;', database_name], stdin=subprocess.PIPE, @@ -64,14 +65,15 @@ def mysql(database_name, username, password): sql_showtables, stderr = p.communicate() tables = [re.sub( '\|\s+([^\|*])\s+.*', '\1', x) for x in sql_showtables.split()[1:]] - connection_string = "legacy_db = DAL('mysql://%s:%s@localhost/%s')" % ( - username, password, database_name) + connection_string = "legacy_db = DAL('mysql://%s:%s@%s/%s')" % ( + username, password, host, database_name) legacy_db_table_web2py_code = [] for table_name in tables: #get the sql create statement p = subprocess.Popen(['mysqldump', '--user=%s' % username, '--password=%s' % password, + '--host=%s' % host, '--skip-add-drop-table', '--no-data', database_name, table_name], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -106,9 +108,13 @@ def mysql(database_name, username, password): legacy_db_table_web2py_code) return legacy_db_web2py_code -regex = re.compile('(.*?):(.*?)@(.*)') +regex = re.compile('(.*):(.*)@((.*)/)?(.*)') if len(sys.argv) < 2 or not regex.match(sys.argv[1]): - print 'USAGE:\n\n extract_mysql_models.py username:password@data_basename\n\n' + print 'USAGE:\n\n extract_mysql_models.py username:password@[host/]data_basename\n\n' else: m = regex.match(sys.argv[1]) - print mysql(m.group(3), m.group(1), m.group(2)) + username = m.group(1) + password = m.group(2) + host = m.group(4) or 'localhost' + db_name = m.group(5) + print mysql(database_name = db_name, username = username, password = password, host = host) From d51ea90e1838ffde0481137b708f2538c4ff3eb8 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 11 Nov 2016 15:49:28 -0800 Subject: [PATCH 5/8] Code fix to allow adding markmin translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Playing with this file made me realize that the quotes defining the strings themselves are added to the regex searches, and that my previous addition caused invalid syntax. So, I decided to fix this by placing the first quote before the markmin decorator. (Triple quotes won’t work, however…) --- gluon/languages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/languages.py b/gluon/languages.py index afc5b3324..ff9ff4cf6 100644 --- a/gluon/languages.py +++ b/gluon/languages.py @@ -962,7 +962,7 @@ def findT(path, language=DEFAULT_LANGUAGE): + listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0): data = to_native(read_locked(filename)) items = regex_translate.findall(data) - items += ["@markmin\x01%s" %x for x in regex_translate_m.findall(data)] + for x in regex_translate_m.findall(data): items.append("%s@markmin\x01%s" %(x[0], x[1:])) for item in items: try: message = safe_eval(item) From 90ee6f3754c324709073bf858b3c5c1234255b5e Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 11 Nov 2016 15:51:01 -0800 Subject: [PATCH 6/8] Add three-quote support on markmin --- gluon/languages.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gluon/languages.py b/gluon/languages.py index ff9ff4cf6..0faedf33e 100644 --- a/gluon/languages.py +++ b/gluon/languages.py @@ -962,7 +962,9 @@ def findT(path, language=DEFAULT_LANGUAGE): + listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0): data = to_native(read_locked(filename)) items = regex_translate.findall(data) - for x in regex_translate_m.findall(data): items.append("%s@markmin\x01%s" %(x[0], x[1:])) + for x in regex_translate_m.findall(data): + if x[0:3] in ["'''", '"""']: items.append("%s@markmin\x01%s" %(x[0:3], x[3:])) + else: items.append("%s@markmin\x01%s" %(x[0], x[1:])) for item in items: try: message = safe_eval(item) From 2c70a858f14a0fed504a3a10306e7b24ec128b60 Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Thu, 17 Nov 2016 13:30:11 +0100 Subject: [PATCH 7/8] implemented base support for CASv3 --- gluon/tools.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gluon/tools.py b/gluon/tools.py index 664f2f565..053dc9adf 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2005,6 +2005,12 @@ def authentication(): return self.cas_validate(version=2, proxy=False) elif args(1) == self.settings.cas_actions['proxyvalidate']: return self.cas_validate(version=2, proxy=True) + elif (args(1) == 'p3' + and args(2) == self.settings.cas_actions['servicevalidate']): + return self.cas_validate(version=3, proxy=False) + elif (args(1) == 'p3' + and args(2) == self.settings.cas_actions['proxyvalidate']): + return self.cas_validate(version=3, proxy=True) elif args(1) == self.settings.cas_actions['logout']: return self.logout(next=request.vars.service or DEFAULT) else: @@ -2830,6 +2836,15 @@ def build_response(body): if success: if version == 1: message = 'yes\n%s' % user[userfield] + elif version == 3: + username = user.get('username', user[userfield]) + message = build_response( + TAG['cas:authenticationSuccess']( + TAG['cas:user'](username), + TAG['cas:attributes']( + *[TAG['cas:' + field.name](user[field.name]) + for field in self.table_user() + if field.readable]))) else: # assume version 2 username = user.get('username', user[userfield]) message = build_response( @@ -7072,4 +7087,4 @@ def save(self, options): if __name__ == '__main__': import doctest - doctest.testmod() \ No newline at end of file + doctest.testmod() From 0b8ecea4dcd667689e835ab82286ec079b903191 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 21 Nov 2016 10:27:16 -0600 Subject: [PATCH 8/8] sudo: required, thanks Leonel --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 472896fdb..3bc79dcc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python -sudo: false +sudo: required cache: pip