Skip to content

Commit 34587a5

Browse files
committed
Only allow single unary plus
1 parent 38d850c commit 34587a5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/input/shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn clean_int_str(mut s: &str) -> Option<Cow<str>> {
115115
s = s.trim();
116116

117117
// strip leading unary plus
118-
s = s.trim_start_matches('+');
118+
s = s.strip_prefix('+').unwrap_or(s);
119119

120120
// strip loading zeros
121121
s = strip_leading_zeros(s)?;

tests/validators/test_int.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
('+0_42', 42),
4848
('+4_2.0', 42),
4949
('+04_2.0', 42),
50+
('++4_2', Err('Input should be a valid integer, unable to parse string as an integer')),
5051
('4_2', 42),
5152
('0_42', 42),
5253
('4_2.0', 42),

0 commit comments

Comments
 (0)