Codebase list cairosvg / f9f06c4
New upstream version 2.5.2 Michael Fladischer 2 years ago
7 changed file(s) with 63 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
00 ======
11 News
22 ======
3
4
5 Version 2.5.2 released on 2021-03-06
6 ====================================
7
8 * Fix marker path scale
9
10 Version 2.5.1 released on 2021-01-06
11 ====================================
12
13 **WARNING:** this is a security update.
14
15 When processing SVG files, CairoSVG was using two regular expressions which are
16 vulnerable to Regular Expression Denial of Service (REDoS).
17
18 If an attacker provided a malicious SVG, it could make CairoSVG get stuck
19 processing the file for a very long time.
20
21 Other bug fixes:
22
23 * Fix marker positions for unclosed paths
24 * Follow hint when only output_width or output_height is set
25 * Handle opacity on raster images
26 * Don’t crash when use tags reference unknown tags
27 * Take care of the next letter when A/a is replaced by l
28 * Fix misalignment in node.vertices
329
430
531 Version 2.5.0 released on 2020-10-29
0 2.5.0
0 2.5.2
186186 'transparent': (0, 0, 0, 0),
187187 }
188188
189 RGBA = re.compile(r'rgba\([ \n\r\t]*(.+?)[ \n\r\t]*\)')
190 RGB = re.compile(r'rgb\([ \n\r\t]*(.+?)[ \n\r\t]*\)')
189 RGBA = re.compile(r'rgba\((.+?)\)')
190 RGB = re.compile(r'rgb\((.+?)\)')
191191 HEX_RRGGBB = re.compile('#[0-9a-f]{6}')
192192 HEX_RGB = re.compile('#[0-9a-f]{3}')
193193
211211 if match:
212212 r, g, b, a = tuple(
213213 float(i.strip(' %')) / 100 if '%' in i else float(i) / 255
214 for i in match.group(1).split(','))
214 for i in match.group(1).strip().split(','))
215215 return (r, g, b, a * 255 * opacity)
216216
217217 match = RGB.search(string)
218218 if match:
219219 r, g, b = tuple(
220220 float(i.strip(' %')) / 100 if '%' in i else float(i) / 255
221 for i in match.group(1).split(','))
221 for i in match.group(1).strip().split(','))
222222 return (r, g, b, opacity)
223223
224224 match = HEX_RRGGBB.search(string)
345345 if 'mask' in node:
346346 del node['mask']
347347 href = parse_url(node.get_href()).geturl()
348 tree = Tree(
349 url=href, url_fetcher=node.url_fetcher, parent=node,
350 tree_cache=surface.tree_cache, unsafe=node.unsafe)
348 try:
349 tree = Tree(
350 url=href, url_fetcher=node.url_fetcher, parent=node,
351 tree_cache=surface.tree_cache, unsafe=node.unsafe)
352 except TypeError:
353 surface.context.restore()
354 return
351355
352356 if not match_features(tree.xml_tree):
353357 surface.context.restore()
101101 surface.context.clip()
102102
103103 # Paint raster image
104 opacity = float(node.get('opacity', 1))
104105 surface.context.save()
105106 surface.context.translate(x, y)
106107 surface.context.scale(scale_x, scale_y)
107108 surface.context.translate(translate_x, translate_y)
108109 surface.context.set_source(image_surface.pattern)
109 surface.context.paint()
110 surface.context.paint_with_alpha(opacity)
110111 surface.context.restore()
111112
112113
185185
186186 # rx=0 or ry=0 means straight line
187187 if not rx or not ry:
188 string = 'l {} {} {}'.format(x3, y3, string)
188 if string and string[0] not in PATH_LETTERS:
189 # As we replace the current operation by l, we must be sure
190 # that the next letter is set to the real current letter (a
191 # or A) in case it’s omitted
192 next_letter = '{} '.format(letter)
193 else:
194 next_letter = ''
195 string = 'l {} {} {}{}'.format(x3, y3, next_letter, string)
189196 continue
190197
191198 radii_ratio = ry / rx
305312 elif letter == 'm':
306313 # Current point relative move
307314 x, y, string = point(surface, string)
315 if last_letter and last_letter not in 'zZ':
316 node.vertices.append(None)
308317 surface.context.rel_move_to(x, y)
309318 current_point = current_point[0] + x, current_point[1] + y
310319
311320 elif letter == 'M':
312321 # Current point move
313322 x, y, string = point(surface, string)
323 if last_letter and last_letter not in 'zZ':
324 node.vertices.append(None)
314325 surface.context.move_to(x, y)
315326 current_point = x, y
316327
421432 # Vertical line
422433 y, string = (string + ' ').split(' ', 1)
423434 old_x, old_y = current_point
424 angle = pi / 2 if size(surface, y, 'y') > 0 else -pi / 2
435 angle = pi / 2 if size(surface, y, 'y') > old_y else -pi / 2
425436 node.vertices.append((-angle, angle))
426437 y = size(surface, y, 'y')
427438 surface.context.line_to(old_x, y)
183183
184184 if output_width and output_height:
185185 width, height = output_width, output_height
186 elif output_width:
187 if width:
188 # Keep the aspect ratio
189 height *= output_width / width
190 width = output_width
191 elif output_height:
192 if height:
193 # Keep the aspect ratio
194 width *= output_height / height
195 height = output_height
186196 else:
187197 width *= scale
188198 height *= scale