diff --git a/src/stitch/api/mermaid/diagram.rs b/src/stitch/api/mermaid/diagram.rs index 7808d6a..8e0e4ce 100644 --- a/src/stitch/api/mermaid/diagram.rs +++ b/src/stitch/api/mermaid/diagram.rs @@ -1,6 +1,6 @@ use super::service_oper_graph::{LinkType, Position, ServiceOperGraph, ServiceOperationType}; use crate::{stats::CChainStatsKey, Stitched}; -use regex::Regex; +use regex::{self, Regex}; use std::collections::HashMap; struct CountedPrefix(HashMap); @@ -34,9 +34,10 @@ fn split_service(service_oper: &str) -> &str { /// 1. find all paths in 'data' that touch 'service_oper' and construct the graph including the counts (statistics). In this stage we also collect that paths leading to 'service_oper' /// 2. The (deduplicated) set of all paths leading into 'service_oper' are used to construct all the upstream process-steps. However, we do not have count-statistics for these paths fn build_serv_oper_graph(data: &Stitched, service_oper: &str) -> ServiceOperGraph { + let esc_service_oper = regex::escape(service_oper); let re_service_oper = - Regex::new(service_oper).expect("Failed to create regex for service_oper"); - let re_so_prefix = Regex::new(&format!("^.*{}", service_oper)) + Regex::new(&esc_service_oper).expect("Failed to create regex for service_oper"); + let re_so_prefix = Regex::new(&format!("^.*{}", esc_service_oper)) .expect("Failed to create regex for service_oper_prefix"); let service = split_service(service_oper); diff --git a/src/stitch/api/utils.rs b/src/stitch/api/utils.rs index 7a85230..8b04043 100644 --- a/src/stitch/api/utils.rs +++ b/src/stitch/api/utils.rs @@ -4,7 +4,7 @@ use super::{ }; use crate::{BestFit, Stitched, StitchedLine, StitchedSet}; use log::error; -use regex::Regex; +use regex::{self, Regex}; use std::cmp::Ordering; const DEFAULT_RANK: f64 = -1.0; // indicates growth not defined @@ -199,7 +199,8 @@ fn get_call_chain_list_end2end( all_chains: bool, inbound_idx_filter: Option, ) -> ProcessList { - let re_proc_oper = Regex::new(proc_oper).expect("Failed to create regex for proc_oper"); + let esc_proc_oper = regex::escape(proc_oper); + let re_proc_oper = Regex::new(&esc_proc_oper).expect("Failed to create regex for proc_oper"); let inbound_prefix_idx = InboundPrefixIdx::new(data, proc_oper);