Skip to content

Commit 63d6a30

Browse files
Enguerrand ARMINJON WINDOWSEArminjon
Enguerrand ARMINJON WINDOWS
authored andcommitted
[vector_graphics_compiler] fix-null-exception
1 parent 72356fd commit 63d6a30

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

packages/vector_graphics_compiler/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.15
2+
3+
* Fixes an issue where empty tag could throw and broke SVG.
4+
15
## 1.1.14
26

37
* Makes the package WASM compatible.

packages/vector_graphics_compiler/lib/src/svg/parser.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ class SvgParser {
895895
return false;
896896
}
897897
final ParentNode parent = _parentDrawables.last.drawable;
898-
final Path path = pathFunc(this)!;
898+
final Path? path = pathFunc(this);
899+
if (path == null) {
900+
return false;
901+
}
899902
final PathNode drawable = PathNode(path, _currentAttributes);
900903
checkForIri(drawable);
901904

packages/vector_graphics_compiler/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: vector_graphics_compiler
22
description: A compiler to convert SVGs to the binary format used by `package:vector_graphics`.
33
repository: https://github.com/flutter/packages/tree/main/packages/vector_graphics_compiler
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_graphics%22
5-
version: 1.1.14
5+
version: 1.1.15
66

77
executables:
88
vector_graphics_compiler:

packages/vector_graphics_compiler/test/parser_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:io';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:vector_graphics_compiler/src/svg/numbers.dart';
99
import 'package:vector_graphics_compiler/vector_graphics_compiler.dart';
10+
1011
import 'test_svg_strings.dart';
1112

1213
void main() {
@@ -1948,6 +1949,19 @@ void main() {
19481949
],
19491950
);
19501951
});
1952+
1953+
test('Parse empty tag', () {
1954+
const String svgStr = '''
1955+
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
1956+
<polygon
1957+
fill="#0a287d"
1958+
points=""
1959+
id="triangle"/>
1960+
</svg>
1961+
''';
1962+
1963+
expect(parseWithoutOptimizers(svgStr), isA<VectorInstructions>());
1964+
});
19511965
}
19521966

19531967
const List<Paint> ghostScriptTigerPaints = <Paint>[

0 commit comments

Comments
 (0)