(8f650fc) Refuse a tab in a tag annotation, and bump to 0.32.5
This commit is contained in:
+21
-8
@@ -162,22 +162,35 @@ fn tag_value(raw: &str) -> Result<String, String> {
|
||||
Ok(value.to_string())
|
||||
}
|
||||
|
||||
/// Reject an annotation line that would be read back as a tag of its own.
|
||||
/// Reject an annotation the vocabulary file or the listing cannot carry.
|
||||
///
|
||||
/// The vocabulary is one heading per tag with its prose under it, so a line of prose
|
||||
/// starting with the section marker would split the annotation and declare whatever
|
||||
/// followed. Refused at parse time, where nothing has been written, rather than escaped on
|
||||
/// the way in: an annotation is prose, and quietly rewriting prose is worse than asking for
|
||||
/// a different line.
|
||||
/// followed. A tab anywhere in the value is refused for the listing's sake rather than the
|
||||
/// file's: `tags ls` prints one tag, its count and the annotation's opening line as three
|
||||
/// tab-separated fields, so an annotation holding a tab reads as the start of a fourth
|
||||
/// field and everything after it is silently gone.
|
||||
///
|
||||
/// Both are refused at parse time, where nothing has been written, rather than escaped on
|
||||
/// the way in: an annotation is prose, and quietly rewriting prose is worse than asking
|
||||
/// for a different line.
|
||||
fn annotation_line(raw: &str) -> Result<String, String> {
|
||||
match raw.lines().any(|line| line.starts_with(crate::tag::SECTION)) {
|
||||
true => Err(format!(
|
||||
if raw.lines().any(|line| line.starts_with(crate::tag::SECTION)) {
|
||||
return Err(format!(
|
||||
"an annotation line cannot start with '{}', which is how the vocabulary file \
|
||||
starts a tag",
|
||||
crate::tag::SECTION
|
||||
)),
|
||||
false => Ok(raw.to_string()),
|
||||
));
|
||||
}
|
||||
|
||||
if raw.contains('\t') {
|
||||
return Err(
|
||||
"an annotation cannot contain a tab, which is how `tags ls` separates its fields"
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// What `--actor` says on every command that writes a history entry.
|
||||
|
||||
Reference in New Issue
Block a user