julianfoad_at_apache.org wrote on Tue, 29 Oct 2019 17:22 +00:00:
> +++ subversion/trunk/tools/dist/release.py Tue Oct 29 17:22:40 2019
> @@ -1188,8 +1188,9 @@ def move_to_dist(args):
> def write_news(args):
> 'Write text for the Subversion website.'
> - data = { 'date' : datetime.date.today().strftime('%Y%m%d'),
> - 'date_pres' : datetime.date.today().strftime('%Y-%m-%d'),
> + release_date = args.news_release_date or datetime.date.today().strftime('%Y-%m-%d')
> + data = { 'date' : re.sub("-", "", release_date), # format YYYYmmdd
You don't do any input validation on the date in argv anywhere, so
--news-release-date=foo-bar would be accepted here, as would
--news-release-date=2020-1-1 without leading zeroes.
I assume the lack of leading zeroes would cause problems at some point
down the road (for example, if we ever try to use the 'date' or
'date_pres' replaceables in a context that actually parses them as
date strings, such as the ?update= parameter to download.cgi).
I suggest instead:
release_date = time.strptime(args.news_release_date, "YYYY-mm-dd") if args.news_release_date else datetime.date.today()
… { 'date': release_date.strftime("YYYYmmdd"),
'date_pres': release_date.strftime(…) }
Cheers,
Daniel
> + 'date_pres' : release_date, # format YYYY-mm-dd
> 'major-minor' : args.version.branch,
> 'version' : str(args.version),
> 'version_base' : args.version.base,
> @@ -1796,6 +1797,9 @@ def main():
> subparser.set_defaults(func=write_news)
> subparser.add_argument('--announcement-url',
> help='''The URL to the archived announcement email.''')
> + subparser.add_argument('--news-release-date',
> + help='''The release date for the news, as YYYY-MM-DD.
> + Default: today.''')
> subparser.add_argument('--edit-html-file',
> help='''Insert the text into this file
> news.html, index.html).''')
>
>
>
Received on 2019-10-29 19:05:00 CET