-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,14 +162,19 @@ pub enum License { | |
/// The entry is derived from the email format of `John Doe <[email protected]>`. You need to | ||
/// provide at least name or email. | ||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] | ||
#[serde(untagged, expecting = "a table with 'name' and/or 'email' keys")] | ||
// deny_unknown_fields prevents using the name field when the email is not a string. | ||
#[serde( | ||
untagged, | ||
deny_unknown_fields, | ||
expecting = "a table with 'name' and/or 'email' keys" | ||
)] | ||
pub enum Contact { | ||
/// TODO(konsti): RFC 822 validation. | ||
NameEmail { name: String, email: String }, | ||
/// TODO(konsti): RFC 822 validation. | ||
Name { name: String }, | ||
/// TODO(konsti): RFC 822 validation. | ||
Email { email: String }, | ||
/// TODO(konsti): RFC 822 validation. | ||
NameEmail { name: String, email: String }, | ||
} | ||
|
||
/// The `[dependency-groups]` section of pyproject.toml, as specified in PEP 735 | ||
|
@@ -475,4 +480,27 @@ iota = [{include-group = "alpha"}] | |
}] | ||
); | ||
} | ||
|
||
#[test] | ||
fn invalid_email() { | ||
let source = r#" | ||
[project] | ||
name = "hello-world" | ||
version = "0.1.0" | ||
# Ensure that the spans from toml handle utf-8 correctly | ||
authors = [ | ||
{ name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 } | ||
] | ||
"#; | ||
let err = PyProjectToml::new(source).unwrap_err(); | ||
assert_eq!( | ||
err.to_string(), | ||
"TOML parse error at line 6, column 11 | ||
| | ||
6 | authors = [ | ||
| ^ | ||
a table with 'name' and/or 'email' keys | ||
" | ||
); | ||
} | ||
} |