Skip to content

Commit

Permalink
fix(vrl): update unquoted allowed-characters (#14114)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMertz authored and jszwedko committed Aug 30, 2022
1 parent dcc70f3 commit d37e8de
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/lookup/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
use regex::Regex;

static VALID_FIELD: Lazy<Regex> =
Lazy::new(|| Regex::new("^[0-9]*[a-zA-Z_][0-9a-zA-Z_]*$").unwrap());
Lazy::new(|| Regex::new("^[0-9]*[a-zA-Z_@][0-9a-zA-Z_@]*$").unwrap());

/// A valid fieldname can contain alphanumeric characters and an underscore.
/// It may start with a number, but has to consist of more than just a number.
Expand Down
2 changes: 1 addition & 1 deletion lib/lookup/src/path.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PathSegment: Segment<'input> = {
}

Field: Field<'input> = {
<s:r"[0-9]*[a-zA-Z_][0-9a-zA-Z_]*"> => Field::from(s),
<s:r"[0-9]*[a-zA-Z_@][0-9a-zA-Z_@]*"> => Field::from(s),
<s:r#""(\\"|[^"])+""#> => Field::from(s),
}

Expand Down
4 changes: 2 additions & 2 deletions lib/vrl/compiler/src/expression/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ fn verify_overwriteable(
let (variant, segment_span, valid) = match last {
segment @ (SegmentBuf::Field(_) | SegmentBuf::Coalesce(_)) => {
let segment_str = segment.to_string();
let segment_start = parent_span.end() - segment_str.len();
let segment_start = parent_span.end().saturating_sub(segment_str.len());
let segment_span = Span::new(segment_start, parent_span.end());

parent_span = Span::new(parent_span.start(), segment_start - 1);
parent_span = Span::new(parent_span.start(), segment_start.saturating_sub(1));
remainder_str.insert_str(0, &format!(".{}", segment_str));

("object", segment_span, parent_kind.contains_object())
Expand Down
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/1.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
.(a|b) = true
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/2.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
.("a b" | c) = true
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/3.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
."foo @bar".baz = true
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/4.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
.@@foo = true
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/5.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
.@foo = true
2 changes: 2 additions & 0 deletions lib/vrl/tests/tests/issues/13461/6.vrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# result: true
."$foo" = true

0 comments on commit d37e8de

Please sign in to comment.