Commit d9f97bc5 authored by Varun Khaneja's avatar Varun Khaneja Committed by Commit Bot

Use https for short URLs wherever applicable (MoarTLS).

Tested for: crrev.com/c/, crrev.com/i, crbug.com/

Bug:
Change-Id: I4fcc316f454894acc9177f731dffbeb75ed3e2ad
Reviewed-on: https://chromium-review.googlesource.com/597427
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
parent c9353605
...@@ -70,6 +70,7 @@ rietveld_instances = [ ...@@ -70,6 +70,7 @@ rietveld_instances = [
'supports_owner_modified_query': True, 'supports_owner_modified_query': True,
'requires_auth': False, 'requires_auth': False,
'email_domain': 'chromium.org', 'email_domain': 'chromium.org',
'short_url_protocol': 'https',
}, },
{ {
'url': 'chromereviews.googleplex.com', 'url': 'chromereviews.googleplex.com',
...@@ -96,10 +97,12 @@ gerrit_instances = [ ...@@ -96,10 +97,12 @@ gerrit_instances = [
{ {
'url': 'chromium-review.googlesource.com', 'url': 'chromium-review.googlesource.com',
'shorturl': 'crrev.com/c', 'shorturl': 'crrev.com/c',
'short_url_protocol': 'https',
}, },
{ {
'url': 'chrome-internal-review.googlesource.com', 'url': 'chrome-internal-review.googlesource.com',
'shorturl': 'crrev.com/i', 'shorturl': 'crrev.com/i',
'short_url_protocol': 'https',
}, },
{ {
'url': 'android-review.googlesource.com', 'url': 'android-review.googlesource.com',
...@@ -110,6 +113,7 @@ google_code_projects = [ ...@@ -110,6 +113,7 @@ google_code_projects = [
{ {
'name': 'chromium', 'name': 'chromium',
'shorturl': 'crbug.com', 'shorturl': 'crbug.com',
'short_url_protocol': 'https',
}, },
{ {
'name': 'google-breakpad', 'name': 'google-breakpad',
...@@ -299,11 +303,14 @@ class MyActivity(object): ...@@ -299,11 +303,14 @@ class MyActivity(object):
ret['reviewers'] = set(issue['reviewers']) ret['reviewers'] = set(issue['reviewers'])
shorturl = instance['url']
if 'shorturl' in instance: if 'shorturl' in instance:
shorturl = instance['shorturl'] url = instance['shorturl']
protocol = instance.get('short_url_protocol', 'http')
else:
url = instance['url']
protocol = 'https'
ret['review_url'] = 'http://%s/%d' % (shorturl, issue['issue']) ret['review_url'] = '%s://%s/%d' % (protocol, url, issue['issue'])
# Rietveld sometimes has '\r\n' instead of '\n'. # Rietveld sometimes has '\r\n' instead of '\n'.
ret['header'] = issue['description'].replace('\r', '').split('\n')[0] ret['header'] = issue['description'].replace('\r', '').split('\n')[0]
...@@ -388,10 +395,13 @@ class MyActivity(object): ...@@ -388,10 +395,13 @@ class MyActivity(object):
'+{insertions},-{deletions}', '+{insertions},-{deletions}',
**issue) **issue)
ret['status'] = issue['status'] ret['status'] = issue['status']
ret['review_url'] = issue['url']
if 'shorturl' in instance: if 'shorturl' in instance:
ret['review_url'] = 'http://%s/%s' % (instance['shorturl'], protocol = instance.get('short_url_protocol', 'http')
ret['review_url'] = '%s://%s/%s' % (protocol, instance['shorturl'],
issue['number']) issue['number'])
else:
ret['review_url'] = issue['url']
ret['header'] = issue['subject'] ret['header'] = issue['subject']
ret['owner'] = issue['owner']['email'] ret['owner'] = issue['owner']['email']
ret['author'] = ret['owner'] ret['author'] = ret['owner']
...@@ -425,12 +435,14 @@ class MyActivity(object): ...@@ -425,12 +435,14 @@ class MyActivity(object):
'+{insertions},-{deletions}', '+{insertions},-{deletions}',
**issue) **issue)
ret['status'] = issue['status'] ret['status'] = issue['status']
ret['review_url'] = 'https://%s/%s' % (instance['url'], issue['_number'])
if 'shorturl' in instance: if 'shorturl' in instance:
# TODO(deymo): Move this short link to https once crosreview.com supports protocol = instance.get('short_url_protocol', 'http')
# it. url = instance['shorturl']
ret['review_url'] = 'http://%s/%s' % (instance['shorturl'], else:
issue['_number']) protocol = 'https'
url = instance['url']
ret['review_url'] = '%s://%s/%s' % (protocol, url, issue['_number'])
ret['header'] = issue['subject'] ret['header'] = issue['subject']
ret['owner'] = issue['owner']['email'] ret['owner'] = issue['owner']['email']
ret['author'] = ret['owner'] ret['author'] = ret['owner']
...@@ -487,7 +499,8 @@ class MyActivity(object): ...@@ -487,7 +499,8 @@ class MyActivity(object):
items = content['items'] items = content['items']
for item in items: for item in items:
if instance.get('shorturl'): if instance.get('shorturl'):
item_url = 'https://%s/%d' % (instance['shorturl'], item['id']) protocol = instance.get('short_url_protocol', 'http')
item_url = '%s://%s/%d' % (protocol, instance['shorturl'], item['id'])
else: else:
item_url = 'https://bugs.chromium.org/p/%s/issues/detail?id=%d' % ( item_url = 'https://bugs.chromium.org/p/%s/issues/detail?id=%d' % (
instance['name'], item['id']) instance['name'], item['id'])
...@@ -502,9 +515,6 @@ class MyActivity(object): ...@@ -502,9 +515,6 @@ class MyActivity(object):
'labels': [], 'labels': [],
'components': [] 'components': []
} }
if 'shorturl' in instance:
issue['url'] = 'http://%s/%d' % (instance['shorturl'], item['id'])
if 'owner' in item: if 'owner' in item:
issue['owner'] = item['owner']['name'] issue['owner'] = item['owner']['name']
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment