[librsvg] (#345): path_parser.rs: Numbers must have digits; they can't consist of a single dot
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] (#345): path_parser.rs: Numbers must have digits; they can't consist of a single dot
- Date: Sat, 22 Sep 2018 01:54:31 +0000 (UTC)
commit 78c2ab108ed38017f62fdaf48f9758c8b8064e4a
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Sep 21 20:20:51 2018 -0500
(#345): path_parser.rs: Numbers must have digits; they can't consist of a single dot
https://gitlab.gnome.org/GNOME/librsvg/issues/345
rsvg_internals/src/path_parser.rs | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/rsvg_internals/src/path_parser.rs b/rsvg_internals/src/path_parser.rs
index 0f0b0654..b5de38f5 100644
--- a/rsvg_internals/src/path_parser.rs
+++ b/rsvg_internals/src/path_parser.rs
@@ -192,6 +192,7 @@ impl<'b> PathParser<'b> {
sign = -1.0;
}
+ let mut has_integer_part = false;
let mut value: f64;
let mut exponent_sign: f64;
let mut exponent: Option<f64>;
@@ -205,6 +206,7 @@ impl<'b> PathParser<'b> {
if self.lookahead_is_digit(&mut c) || self.lookahead_is('.') {
// Integer part
while self.lookahead_is_digit(&mut c) {
+ has_integer_part = true;
value = value * 10.0 + f64::from(char_to_digit(c));
assert!(self.match_char(c));
@@ -216,6 +218,12 @@ impl<'b> PathParser<'b> {
let mut c: char = ' ';
+ if !has_integer_part {
+ if !self.lookahead_is_digit(&mut c) {
+ return Err(self.error(ErrorKind::UnexpectedToken));
+ }
+ }
+
while self.lookahead_is_digit(&mut c) {
fraction /= 10.0;
value += fraction * f64::from(char_to_digit(c));
@@ -2182,4 +2190,15 @@ mod tests {
// arc(...)],
// Some(ErrorKind::UnexpectedEof));
}
+
+ #[test]
+ fn bugs() {
+ // https://gitlab.gnome.org/GNOME/librsvg/issues/345
+ test_parser(
+ "M.. 1,0 0,100000",
+ " ^",
+ &vec![],
+ Some(ErrorKind::UnexpectedToken),
+ );
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]