ENH:filter domain names in network errors

Change-Id: I86d7f11bb198ac9060a1f1d6e6432f39471c70fb
This commit is contained in:
tao wang 2023-05-24 15:29:05 +08:00 committed by Lane.Wei
parent 8714b3e5e5
commit 6591d1d0ed
5 changed files with 27 additions and 6 deletions

View file

@ -520,8 +520,8 @@ wxString get_fail_reason(int code)
m_sw_bind_failed_info->Show(true);
m_st_txt_error_code->SetLabelText(wxString::Format("%d", m_result_code));
m_st_txt_error_desc->SetLabelText(m_result_info);
m_st_txt_extra_info->SetLabelText(m_result_extra);
m_st_txt_error_desc->SetLabelText( wxGetApp().filter_string(m_result_info));
m_st_txt_extra_info->SetLabelText( wxGetApp().filter_string(m_result_extra));
m_st_txt_error_code->Wrap(FromDIP(260));
m_st_txt_error_desc->Wrap(FromDIP(260));

View file

@ -5568,6 +5568,26 @@ void GUI_App::preset_deleted_from_cloud(std::string setting_id)
need_delete_presets.erase(std::remove(need_delete_presets.begin(), need_delete_presets.end(), setting_id), need_delete_presets.end());
}
wxString GUI_App::filter_string(wxString str)
{
std::string result = str.ToStdString();
std::string input = str.ToStdString();
std::regex domainRegex(R"(([a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\.[a-zA-Z]{2,})?))");
std::sregex_iterator it(input.begin(), input.end(), domainRegex);
std::sregex_iterator end;
while (it != end) {
std::smatch match = *it;
std::string domain = match.str();
result.replace(match.position(), domain.length(), "[***]");
++it;
}
return result;
}
bool GUI_App::OnExceptionInMainLoop()
{
generic_exception_handle();

View file

@ -489,6 +489,7 @@ public:
void delete_preset_from_cloud(std::string setting_id);
void preset_deleted_from_cloud(std::string setting_id);
wxString filter_string(wxString str);
wxString current_language_code() const { return m_wxLocale->GetCanonicalName(); }
// Translate the language code to a code, for which Prusa Research maintains translations. Defaults to "en_US".
wxString current_language_code_safe() const;

View file

@ -1517,8 +1517,8 @@ void SelectMachineDialog::show_print_failed_info(bool show, int code, wxString d
m_sw_print_failed_info->Show(true);
m_st_txt_error_code->SetLabelText(wxString::Format("%d", m_print_error_code));
m_st_txt_error_desc->SetLabelText(m_print_error_msg);
m_st_txt_extra_info->SetLabelText(m_print_error_extra);
m_st_txt_error_desc->SetLabelText( wxGetApp().filter_string(m_print_error_msg));
m_st_txt_extra_info->SetLabelText( wxGetApp().filter_string(m_print_error_extra));
m_st_txt_error_code->Wrap(FromDIP(260));
m_st_txt_error_desc->Wrap(FromDIP(260));

View file

@ -539,8 +539,8 @@ void SendToPrinterDialog::show_print_failed_info(bool show, int code, wxString d
m_sw_print_failed_info->Show(true);
m_st_txt_error_code->SetLabelText(wxString::Format("%d", m_print_error_code));
m_st_txt_error_desc->SetLabelText(m_print_error_msg);
m_st_txt_extra_info->SetLabelText(m_print_error_extra);
m_st_txt_error_desc->SetLabelText( wxGetApp().filter_string(m_print_error_msg));
m_st_txt_extra_info->SetLabelText( wxGetApp().filter_string(m_print_error_extra));
m_st_txt_error_code->Wrap(FromDIP(260));
m_st_txt_error_desc->Wrap(FromDIP(260));