Skip to content

Commit

Permalink
fix(message): fixed processing of removing special character #1145
Browse files Browse the repository at this point in the history
  • Loading branch information
hitenkoku committed Sep 3, 2023
1 parent 6890b47 commit 0266489
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/detections/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,34 @@ pub fn insert(
) {
let mut record_details_info_map = HashMap::new();
if !is_agg {
let mut prev = 'a';
//ここの段階でdetailsの内容でaliasを置き換えた内容と各種、key,valueの組み合わせのmapを取得する
let (mut removed_sp_parsed_detail, alias_hash_map) = parse_message(
let (mut removed_sp_parsed_detail, details_in_record) = parse_message(
event_record,
output,
eventkey_alias,
is_json_timeline,
field_data_map_key,
field_data_map,
);
record_details_info_map.insert("#Details".into(), alias_hash_map);
// 特殊文字の除外のためのretain処理
removed_sp_parsed_detail.retain(|ch| {
let retain_flag = prev == ' ' && ch == ' ' && ch.is_control();
if !retain_flag {
prev = ch;
}
!retain_flag

let removed_sp_char = |mut cs: CompactString| -> CompactString {
let mut prev = 'a';
cs.retain(|ch| {
let retain_flag = (prev == ' ' && ch == ' ') || ch.is_control();
if !retain_flag {
prev = ch;
}
!retain_flag
});
cs.clone()
};
let mut sp_removed_details_in_record = vec![];
details_in_record.iter().for_each(|v| {
sp_removed_details_in_record.push(removed_sp_char(v.clone()));
});
record_details_info_map.insert("#Details".into(), sp_removed_details_in_record);
// 特殊文字の除外のためのretain処理
removed_sp_parsed_detail = removed_sp_char(removed_sp_parsed_detail);

// Details内にある改行文字は除外しないために絵文字を含めた特殊な文字に変換することで対応する
let parsed_detail = removed_sp_parsed_detail
Expand Down

0 comments on commit 0266489

Please sign in to comment.