components/python/pygments/patches/CVE-2015-8557.patch
changeset 6410 3ae42b2b5dad
parent 6409 a57c61602ca6
child 6411 76a1152cb6f7
equal deleted inserted replaced
6409:a57c61602ca6 6410:3ae42b2b5dad
     1 This patch is pulled from upstream; once we pull in 2.1 or newer, it will
       
     2 no longer be necessary.
       
     3 
       
     4 --- Pygments-1.6/pygments/formatters/img.py	Sun Feb  3 01:26:49 2013
       
     5 +++ Pygments-1.6/pygments/formatters/img.py	Wed Jan 20 13:33:20 2016
       
     6 @@ -15,6 +15,8 @@
       
     7  from pygments.util import get_bool_opt, get_int_opt, \
       
     8       get_list_opt, get_choice_opt
       
     9  
       
    10 +import subprocess
       
    11 +
       
    12  # Import this carefully
       
    13  try:
       
    14      from PIL import Image, ImageDraw, ImageFont
       
    15 @@ -72,11 +74,11 @@
       
    16              self._create_nix()
       
    17  
       
    18      def _get_nix_font_path(self, name, style):
       
    19 -        from commands import getstatusoutput
       
    20 -        exit, out = getstatusoutput('fc-list "%s:style=%s" file' %
       
    21 -                                    (name, style))
       
    22 -        if not exit:
       
    23 -            lines = out.splitlines()
       
    24 +        proc = subprocess.Popen(['fc-list', "%s:style=%s" % (name, style), 'file'],
       
    25 +                                stdout=subprocess.PIPE, stderr=None)
       
    26 +        stdout, _ = proc.communicate()
       
    27 +        if proc.returncode == 0:
       
    28 +            lines = stdout.splitlines()
       
    29              if lines:
       
    30                  path = lines[0].strip().strip(':')
       
    31                  return path