OLD | NEW |
1 | 1 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Utils.""" | 6 """Utils.""" |
7 | 7 |
8 import re | 8 import re |
9 import time | 9 import time |
10 import random | 10 import random |
11 import logging | 11 import logging |
12 import sys | 12 import sys |
13 import string | 13 import string |
14 import json | 14 import json |
| 15 import urllib |
15 | 16 |
16 from google.appengine.api import users | 17 from google.appengine.api import users |
17 | 18 |
18 | 19 |
19 def admin_only(func): | 20 def admin_only(func): |
20 """Valid for BasePage objects only.""" | 21 """Valid for BasePage objects only.""" |
21 def decorated(self, *args, **kwargs): | 22 def decorated(self, *args, **kwargs): |
22 if self.is_admin: | 23 if self.is_admin: |
23 return func(self, *args, **kwargs) | 24 return func(self, *args, **kwargs) |
24 else: | 25 else: |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 def cl_comment(value): | 264 def cl_comment(value): |
264 """Add links to https:// addresses, BUG=####, and trim excessive newlines.""" | 265 """Add links to https:// addresses, BUG=####, and trim excessive newlines.""" |
265 value = re.sub(r'(https?://.*)', r'<a href="\1">\1</a>', value) | 266 value = re.sub(r'(https?://.*)', r'<a href="\1">\1</a>', value) |
266 value = re.sub(r'BUG=([\d,]+)', _resolve_crbug, value) | 267 value = re.sub(r'BUG=([\d,]+)', _resolve_crbug, value) |
267 # Add blockquotes. | 268 # Add blockquotes. |
268 value = _blockquote(value) | 269 value = _blockquote(value) |
269 value = re.sub(r'\n', r'<br>', value) | 270 value = re.sub(r'\n', r'<br>', value) |
270 # Obfuscure email addresses with rot13 encoding. | 271 # Obfuscure email addresses with rot13 encoding. |
271 value = re.sub(r'(\w+@[\w.]+)', lambda m: rot13_email(m.group(1)), value) | 272 value = re.sub(r'(\w+@[\w.]+)', lambda m: rot13_email(m.group(1)), value) |
272 return value | 273 return value |
| 274 |
| 275 def urlquote(value, safe=''): |
| 276 return urllib.quote(value, safe=safe) |
OLD | NEW |