comparison roundup/configuration.py @ 5770:f91da208f26b

Validate that TRACKER_WEB url starts with https:// or http:// and ends with a /.
author John Rouillard <rouilj@ieee.org>
date Wed, 05 Jun 2019 21:11:50 -0400
parents 178ca608ddb9
children 8dbe307bdb57
comparison
equal deleted inserted replaced
5769:9cc3257d0f43 5770:f91da208f26b
490 class MandatoryOption(Option): 490 class MandatoryOption(Option):
491 """Option must not be empty""" 491 """Option must not be empty"""
492 def str2value(self, value): 492 def str2value(self, value):
493 if not value: 493 if not value:
494 raise OptionValueError(self,value,"Value must not be empty.") 494 raise OptionValueError(self,value,"Value must not be empty.")
495 else:
496 return value
497
498 class WebUrlOption(Option):
499 """URL MUST start with http/https scheme and end with '/'"""
500
501 def str2value(self, value):
502 if not value:
503 raise OptionValueError(self,value,"Value must not be empty.")
504
505 error_msg = ''
506 if not value.startswith(('http://', 'https://')):
507 error_msg = "Value must start with http:// or https://.\n"
508
509 if not value.endswith('/'):
510 error_msg += "Value must end with /."
511
512 if error_msg:
513 raise OptionValueError(self,value,error_msg)
495 else: 514 else:
496 return value 515 return value
497 516
498 class NullableOption(Option): 517 class NullableOption(Option):
499 518
712 "See: http://en.wikipedia.org/wiki/PBKDF2 and RFC2898"), 731 "See: http://en.wikipedia.org/wiki/PBKDF2 and RFC2898"),
713 )), 732 )),
714 ("tracker", ( 733 ("tracker", (
715 (Option, "name", "Roundup issue tracker", 734 (Option, "name", "Roundup issue tracker",
716 "A descriptive name for your roundup instance."), 735 "A descriptive name for your roundup instance."),
717 (Option, "web", NODEFAULT, 736 (WebUrlOption, "web", NODEFAULT,
718 "The web address that the tracker is viewable at.\n" 737 "The web address that the tracker is viewable at.\n"
719 "This will be included in information" 738 "This will be included in information"
720 " sent to users of the tracker.\n" 739 " sent to users of the tracker.\n"
721 "The URL MUST include the cgi-bin part or anything else\n" 740 "The URL MUST include the cgi-bin part or anything else\n"
722 "that is required to get to the home page of the tracker.\n" 741 "that is required to get to the home page of the tracker.\n"
723 "You MUST include a trailing '/' in the URL."), 742 "URL MUST start with http/https scheme and end with '/'"),
724 (MailAddressOption, "email", "issue_tracker", 743 (MailAddressOption, "email", "issue_tracker",
725 "Email address that mail to roundup should go to.\n" 744 "Email address that mail to roundup should go to.\n"
726 "If no domain is specified then mail_domain is added."), 745 "If no domain is specified then mail_domain is added."),
727 (Option, "replyto_address", "", 746 (Option, "replyto_address", "",
728 "Controls the reply-to header address used when sending\n" 747 "Controls the reply-to header address used when sending\n"

Roundup Issue Tracker: http://roundup-tracker.org/