Skip to content

Commit 9b16206

Browse files
authored
Merge pull request #116 from bgpkit/fix-utf8-truncation-panic
Fix UTF-8 character handling in name truncation
2 parents 4a762f2 + bd5d290 commit 9b16206

File tree

26 files changed

+93
-68
lines changed

26 files changed

+93
-68
lines changed

CHANGELOG.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,6 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased changes
66

7-
### Breaking Changes
8-
9-
* Moved config, data, and cache paths to follow XDG base directory specification
10-
* Config file default is now `$XDG_CONFIG_HOME/monocle/monocle.toml` (fallback: `~/.config/monocle/monocle.toml`)
11-
* Data directory default is now `$XDG_DATA_HOME/monocle` (fallback: `~/.local/share/monocle`)
12-
* Cache directory default is now `$XDG_CACHE_HOME/monocle` (fallback: `~/.cache/monocle`)
13-
* Existing SQLite data under `~/.monocle` is no longer used by default and will be rebuilt in the new data location
14-
* Legacy config migration: when the new config directory is empty, monocle copies `~/.monocle/monocle.toml` to the new config path
15-
* Old database file will not be copied over. Once the updated monocle has been executed at least once, old `~/.monocle` can be safely deleted
16-
* Added `--use-cache` flag to `monocle search` to use the default XDG cache path (`$XDG_CACHE_HOME/monocle`)
17-
* Value set by `--cache-dir` overrides `--use-cache` when both are provided
18-
19-
### Dependencies
20-
21-
* Switched directory resolution library from `dirs` to `etcetera`
22-
237
### New Features
248

259
* Added BGP community filtering support to `monocle parse` and `monocle search`
@@ -35,9 +19,34 @@ All notable changes to this project will be documented in this file.
3519
* `--ts-start` is now accepted as an alias for `--start-ts`
3620
* `--ts-end` is now accepted as an alias for `--end-ts`
3721

22+
### Bug Fixes
23+
24+
* Fixed panic when truncating names containing non-ASCII UTF-8 characters
25+
* Used character-based truncation instead of byte-based slicing
26+
* Affects RPKI ASPA display and inspect lens name truncation
27+
28+
### Directory Changes
29+
30+
* Changed config, data, and cache paths to follow XDG base directory specification
31+
* Config file default is now `$XDG_CONFIG_HOME/monocle/monocle.toml` (fallback: `~/.config/monocle/monocle.toml`)
32+
* Data directory default is now `$XDG_DATA_HOME/monocle` (fallback: `~/.local/share/monocle`)
33+
* Cache directory default is now `$XDG_CACHE_HOME/monocle` (fallback: `~/.cache/monocle`)
34+
* Existing SQLite data under `~/.monocle` is no longer used by default and will be rebuilt in the new data location
35+
* Legacy config migration: when the new config directory is empty, monocle copies `~/.monocle/monocle.toml` to the new config path
36+
* Old database file will not be copied over. Once the updated monocle has been executed at least once, old `~/.monocle` can be safely deleted
37+
* Added `--use-cache` flag to `monocle search` to use the default XDG cache path (`$XDG_CACHE_HOME/monocle`)
38+
* Value set by `--cache-dir` overrides `--use-cache` when both are provided
39+
3840
### Code Improvements
3941

4042
* Updated README command help examples to match current CLI help output from the release binary
43+
* Moved `utils` module from `lens::utils` to crate-level `utils`
44+
* Eliminates misleading module structure since utilities are used throughout the codebase
45+
* Updated all imports from `crate::lens::utils` and `monocle::lens::utils` to `crate::utils` and `monocle::utils`
46+
47+
### Dependencies
48+
49+
* Switched directory resolution library from `dirs` to `etcetera`
4150

4251
## v1.1.0 - 2025-02-10
4352

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ dateparser = { version = "0.2", optional = true }
158158
humantime = { version = "2.1", optional = true }
159159
bgpkit-broker = { version = "0.10.1", optional = true }
160160
bgpkit-parser = { version = "0.15.0", features = ["serde"], optional = true }
161-
bgpkit-commons = { version = "0.10.1", features = ["asinfo", "rpki", "countries"], optional = true }
161+
bgpkit-commons = { version = "0.10.2", features = ["asinfo", "rpki", "countries"], optional = true }
162162
itertools = { version = "0.14", optional = true }
163163
radar-rs = { version = "0.1.0", optional = true }
164164
rayon = { version = "1.8", optional = true }

src/bin/commands/as2rel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clap::Args;
22
use monocle::database::MonocleDatabase;
33
use monocle::lens::as2rel::{As2relLens, As2relSearchArgs};
4-
use monocle::lens::utils::{truncate_name, OutputFormat, DEFAULT_NAME_MAX_LEN};
4+
use monocle::utils::{truncate_name, OutputFormat, DEFAULT_NAME_MAX_LEN};
55
use monocle::MonocleConfig;
66
use serde::Serialize;
77
use serde_json::json;

src/bin/commands/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use monocle::config::{
66
};
77
use monocle::database::{MonocleDatabase, Pfx2asDbRecord};
88
use monocle::lens::rpki::RpkiLens;
9-
use monocle::lens::utils::OutputFormat;
109
use monocle::server::ServerConfig;
10+
use monocle::utils::OutputFormat;
1111
use monocle::MonocleConfig;
1212
use serde::Serialize;
1313
use std::path::Path;

src/bin/commands/country.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clap::Args;
22
use monocle::lens::country::{CountryEntry, CountryLens, CountryLookupArgs};
3-
use monocle::lens::utils::OutputFormat;
3+
use monocle::utils::OutputFormat;
44
use tabled::settings::Style;
55
use tabled::Table;
66

src/bin/commands/elem_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! multiple output format support.
66
77
use bgpkit_parser::BgpElem;
8-
use monocle::lens::utils::{OrderByField, OrderDirection, OutputFormat, TimestampFormat};
8+
use monocle::utils::{OrderByField, OrderDirection, OutputFormat, TimestampFormat};
99
use serde_json::json;
1010
use tabled::builder::Builder;
1111
use tabled::settings::Style;

src/bin/commands/inspect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use monocle::lens::inspect::{
88
InspectDataSection, InspectDisplayConfig, InspectLens, InspectQueryOptions, InspectQueryType,
99
InspectResult,
1010
};
11-
use monocle::lens::utils::OutputFormat;
11+
use monocle::utils::OutputFormat;
1212
use monocle::MonocleConfig;
1313
use std::collections::HashSet;
1414

src/bin/commands/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clap::Args;
22
use monocle::lens::ip::{IpInfo, IpLens, IpLookupArgs};
3-
use monocle::lens::utils::OutputFormat;
3+
use monocle::utils::OutputFormat;
44
use serde_json::json;
55
use std::net::IpAddr;
66
use tabled::settings::Style;

src/bin/commands/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bgpkit_parser::BgpElem;
66
use clap::Args;
77

88
use monocle::lens::parse::{ParseFilters, ParseLens};
9-
use monocle::lens::utils::{OrderByField, OrderDirection, OutputFormat, TimestampFormat};
9+
use monocle::utils::{OrderByField, OrderDirection, OutputFormat, TimestampFormat};
1010

1111
use super::elem_format::{
1212
available_fields_help, format_elem, format_elems_table, get_header, parse_fields, sort_elems,

0 commit comments

Comments
 (0)