Skip to content

[vector_graphics_compiler] fix-null-exception #8006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vector_graphics_compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.15

* Fixes a bug where empty tags caused the parser to crash.

## 1.1.14

* Makes the package WASM compatible.
Expand Down
5 changes: 4 additions & 1 deletion packages/vector_graphics_compiler/lib/src/svg/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,10 @@ class SvgParser {
return false;
}
final ParentNode parent = _parentDrawables.last.drawable;
final Path path = pathFunc(this)!;
final Path? path = pathFunc(this);
if (path == null) {
return false;
}
final PathNode drawable = PathNode(path, _currentAttributes);
checkForIri(drawable);

Expand Down
2 changes: 1 addition & 1 deletion packages/vector_graphics_compiler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: vector_graphics_compiler
description: A compiler to convert SVGs to the binary format used by `package:vector_graphics`.
repository: https://github.com/flutter/packages/tree/main/packages/vector_graphics_compiler
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_graphics%22
version: 1.1.14
version: 1.1.15

executables:
vector_graphics_compiler:
Expand Down
14 changes: 14 additions & 0 deletions packages/vector_graphics_compiler/test/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:vector_graphics_compiler/src/svg/numbers.dart';
import 'package:vector_graphics_compiler/vector_graphics_compiler.dart';

import 'test_svg_strings.dart';

void main() {
Expand Down Expand Up @@ -1948,6 +1949,19 @@ void main() {
],
);
});

test('Parse empty tag', () {
const String svgStr = '''
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
<polygon
fill="#0a287d"
points=""
id="triangle"/>
</svg>
''';

expect(parseWithoutOptimizers(svgStr), isA<VectorInstructions>());
});
}

const List<Paint> ghostScriptTigerPaints = <Paint>[
Expand Down