Commit 36576334 authored by ilevy@chromium.org's avatar ilevy@chromium.org

Escape paths used in regexs for pylint

This fixes a potential issue with RunPylint in windows where paths
can contain special characters.

TBR=iannucci@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11786007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@175481 0039d316-1c4b-4281-b951-d872f2087c98
parent 9f36c389
......@@ -641,8 +641,11 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None,
error_type = output_api.PresubmitPromptWarning
# Only trigger if there is at least one python file affected.
rel_path = lambda x : input_api.os_path.join(input_api.os_path.relpath(
input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), x)
def rel_path(regex):
"""Modifies a regex for a subject to accept paths relative to root."""
prefix = input_api.os_path.join(input_api.os_path.relpath(
input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '')
return input_api.re.escape(prefix) + regex
src_filter = lambda x: input_api.FilterSourceFile(
x, map(rel_path, white_list), map(rel_path, black_list))
if not input_api.AffectedSourceFiles(src_filter):
......
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