Whitespaces inside the quotation changes the behavior of `TZ="TIMEZONE"`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu trong src/items/timezone.rs và xem xét parser TZ="..." hiện có cùng các test hiện tại của nó. Kiểm tra các trường hợp khoảng trắng được mô tả trong issue, sau đó xác minh rằng parser chấp nhận hành vi khoảng trắng bên trong được đề xuất mà không thay đổi các dạng múi giờ không liên quan khác; hoàn tất nghĩa là các test liên quan đều pass với các offset dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This was a minor comment on https://github.com/uutils/parse_datetime/pull/232#issuecomment-3421283917 and it was suggested to create a separate issue for it
The following is the original copied here:
Hello, thanks to everybody for the great work.
I was studying this PR for a while and I was wondering that is there any reason (beyond performance) on why TZ="VALUE" is not relaxed with inner optional whitespaces (i.e TZ=" VALUE ")? Since such change passes all the current tests, this is a bit confusing to me.
This changes some behavior in an example like the following:
// prefixed whitespace
test(r#"TZ=" UTC-5:20:15""#, fixed_offset(0)); // current
test(r#"TZ=" UTC-5:20:15""#, fixed_offset(19215)); // with relaxed conditions
// prefixed whitespace
test(r#"TZ="UTC-5:20:15 ""#, Err(Backtrack(ContextError { context: [], cause: None }))); // current
test(r#"TZ="UTC-5:20:15 ""#, fixed_offset(19215)); // with relaxed conditions
Naturally, this can be generalized to the cases with :.
Whitespace relaxation can further improve in an unrelated example like: parse_datetime(" TZ=\"...\""). However in parse_datetime example, the user can easily just trim the input while removing the inner spaces of the quotation of this case is not as simple so that's why I think it's a quality improvement (if it is justified to begin with).
Example of changes that will relax this limitation:
diff --git a/src/items/timezone.rs b/src/items/timezone.rs
index 0414ee8..0009d17 100644
--- a/src/items/timezone.rs
+++ b/src/items/timezone.rs
@@ -16,6 +16,7 @@
use jiff::tz::{Offset, TimeZone};
use winnow::{
+ ascii::space0,
combinator::{alt, delimited, opt, preceded, repeat},
stream::AsChar,
token::{one_of, take_while},
@@ -25,7 +26,12 @@ use winnow::{
use super::primitive::{dec_uint, plus_or_minus};
pub(super) fn parse(input: &mut &str) -> ModalResult<TimeZone> {
- delimited("TZ=\"", preceded(opt(':'), alt((posix, iana))), '"').parse_next(input)
+ delimited(
+ ("TZ=\"", space0),
+ preceded(opt((':', space0)), alt((posix, iana))),
+ (space0, "\""),
+ )
+ .parse_next(input)
}
/// Parse a posix (proleptic) timezone string (e.g., "UTC7", "JST-9").
- Ngôn ngữ chính
- Rust
- Star
- 37
- Fork
- 44
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của uutils/parse_datetime
-
date input: unrecognized trailing tokens rejected (e.g. `8j`, `8 j`)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug good first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
uutils/parse_datetime#279 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
uutils/parse_datetime#160 · 10 bình luận ·
-
Fuzzer instructions confusingĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
uutils/parse_datetime#82 ·
-
Cargo test fails at 0:20 JSTCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
uutils/parse_datetime#36 · 4 bình luận · 1 reaction ·
-
Dependency DashboardĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
uutils/parse_datetime#9 ·
Tất cả issue của uutils/parse_datetime
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
eclipse-opensovd/classic-diagnostic-adapter#616 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
track: content
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
0xAndersen/witness-log#10 ·
-
follow-up main-defect wave-A
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
carrick-sh/carrick#249 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
lugassawan/swe-workbench#799 ·
Maintainer thường phản hồi trong vòng 1 ngày