Skip to content
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
11 changes: 9 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,15 @@ impl<'s> VcardParser<'s> {
params.language = Some(tag);
}
VALUE => {
let value: ValueType = value.parse()?;
params.value = Some(value);
if self.strict {
let value: ValueType = value.parse()?;
params.value = Some(value);
} else {
if let Ok(value) = value.parse::<ValueType>()
{
params.value = Some(value);
}
}
}
PREF => {
let value: u8 = value.parse()?;
Expand Down
17 changes: 16 additions & 1 deletion tests/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vcard4::{
Pid, RelatedType, TelephoneType, TimeZoneParameter, TypeParameter,
ValueType,
},
parse, Error,
parse, parse_loose, Error,
};

use test_helpers::{assert_language, assert_media_type, assert_round_trip};
Expand Down Expand Up @@ -368,3 +368,18 @@ END:VCARD"#;

Ok(())
}

// SEE: https://github.com/tmpfs/vcard4/issues/21
#[test]
fn param_nextcloud_ignore_bad_value() -> Result<()> {
let input = r#"BEGIN:VCARD
VERSION:3.0
FN:Example Card2
TEL;TYPE=CELL;VALUE=UNKNOWN:+01555123456
END:VCARD"#;

assert!(parse(input).is_err());
assert!(parse_loose(input).is_ok());

Ok(())
}