Skip to content

Commit

Permalink
Merge pull request #14 from rust-lang/fix-tz-offset-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu authored Nov 8, 2024
2 parents 523e3e2 + 2bfb19a commit eb8cf1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion toml-to-ical/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl<'de> Deserialize<'de> for TimezoneOffset {
return Err(err);
};

if hour == 0 && neg {
if hour == 0 && minute == 0 && neg {
return Err(de::Error::custom("must be `+0000`, not `-0000`"));
}

Expand Down
2 changes: 2 additions & 0 deletions toml-to-ical/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ fn parse_tz_offset() {
assert!(toml::from_str::<Harness>("offset = \"1323\"").is_err());
// Invalid, zeroes can't be negative
assert!(toml::from_str::<Harness>("offset = \"-0000\"").is_err());
// ... but can be positive
assert!(toml::from_str::<Harness>("offset = \"+0000\"").is_ok());
// Invalid, out of range
assert!(toml::from_str::<Harness>("offset = \"+4500\"").is_err());
assert!(toml::from_str::<Harness>("offset = \"-1078\"").is_err());
Expand Down

0 comments on commit eb8cf1d

Please sign in to comment.