| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import os | 6 import os |
| 7 import random | 7 import random |
| 8 import re | 8 import re |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if not '@' in result: | 245 if not '@' in result: |
| 246 log.msg('Invalid blame email address "%s"' % result) | 246 log.msg('Invalid blame email address "%s"' % result) |
| 247 return None | 247 return None |
| 248 if self.permitted_domains: | 248 if self.permitted_domains: |
| 249 for p in self.permitted_domains: | 249 for p in self.permitted_domains: |
| 250 if result.endswith(p): | 250 if result.endswith(p): |
| 251 return result | 251 return result |
| 252 return None | 252 return None |
| 253 return result | 253 return result |
| 254 | 254 |
| 255 # Based on django.utils.html.escapejs from the Django project |
| 256 def EscapeJs(t): |
| 257 """Replaces javascript special characters in the supplied string. |
| 258 |
| 259 Characters are replaced with a textual representation of their integer |
| 260 ordinal.""" |
| 261 js_escapes = { |
| 262 '\\': '\\u005C', |
| 263 '\'': '\\u0027', |
| 264 '"': '\\u0022', |
| 265 '>': '\\u003E', |
| 266 '<': '\\u003C', |
| 267 '&': '\\u0026', |
| 268 '=': '\\u003D', |
| 269 '-': '\\u002D', |
| 270 ';': '\\u003B', |
| 271 u'\u2028': '\\u2028', |
| 272 u'\u2029': '\\u2029', |
| 273 } |
| 274 for k, v in js_escapes.items(): |
| 275 t = t.replace(k, v) |
| 276 return t |
| 255 | 277 |
| 256 def CreateWebStatus(port, templates=None, tagComparator=None, | 278 def CreateWebStatus(port, templates=None, tagComparator=None, |
| 257 customEndpoints=None, console_repo_filter=None, | 279 customEndpoints=None, console_repo_filter=None, |
| 258 console_builder_filter=None, web_template_globals=None, | 280 console_builder_filter=None, web_template_globals=None, |
| 259 **kwargs): | 281 **kwargs): |
| 260 webstatus = WebStatus(port, **kwargs) | 282 webstatus = WebStatus(port, **kwargs) |
| 283 webstatus.templates.filters.update({"escapejs": EscapeJs}) |
| 261 if templates: | 284 if templates: |
| 262 # Manipulate the search path for jinja templates | 285 # Manipulate the search path for jinja templates |
| 263 # pylint: disable=F0401 | 286 # pylint: disable=F0401 |
| 264 import jinja2 | 287 import jinja2 |
| 265 # pylint: disable=E1101 | 288 # pylint: disable=E1101 |
| 266 old_loaders = webstatus.templates.loader.loaders | 289 old_loaders = webstatus.templates.loader.loaders |
| 267 # pylint: disable=E1101 | 290 # pylint: disable=E1101 |
| 268 new_loaders = old_loaders[:1] | 291 new_loaders = old_loaders[:1] |
| 269 new_loaders.extend([jinja2.FileSystemLoader(x) for x in templates]) | 292 new_loaders.extend([jinja2.FileSystemLoader(x) for x in templates]) |
| 270 new_loaders.extend(old_loaders[1:]) | 293 new_loaders.extend(old_loaders[1:]) |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 return result | 740 return result |
| 718 | 741 |
| 719 | 742 |
| 720 def SetMasterProcessName(): | 743 def SetMasterProcessName(): |
| 721 """Sets the name of this process to the name of the master. Linux only.""" | 744 """Sets the name of this process to the name of the master. Linux only.""" |
| 722 | 745 |
| 723 if sys.platform != 'linux2': | 746 if sys.platform != 'linux2': |
| 724 return | 747 return |
| 725 | 748 |
| 726 command_line.set_command_line("master: %s" % GetMastername()) | 749 command_line.set_command_line("master: %s" % GetMastername()) |
| OLD | NEW |