Ticket #2795: hex search: can't find 00 (zeroes) in patterns.

Don't interpret the '0' character as end of search pattern.
Use pattern length for that.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-04-29 16:01:55 +04:00
parent 0646ab6457
commit 13398647ed
2 changed files with 5 additions and 11 deletions

View File

@ -162,7 +162,7 @@ mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_filter = g_new0 (mc_fhl_filter_t, 1); mc_filter = g_new0 (mc_fhl_filter_t, 1);
mc_filter->type = MC_FLHGH_T_FREGEXP; mc_filter->type = MC_FLHGH_T_FREGEXP;
mc_filter->search_condition = mc_search_new (buf->str, -1); mc_filter->search_condition = mc_search_new (buf->str, buf->len);
mc_filter->search_condition->is_case_sensitive = mc_filter->search_condition->is_case_sensitive =
mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE); mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE);
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

View File

@ -259,9 +259,8 @@ mc_search__regex_found_cond_one (mc_search_t * lc_mc_search, mc_search_regex_t *
#ifdef SEARCH_TYPE_GLIB #ifdef SEARCH_TYPE_GLIB
GError *error = NULL; GError *error = NULL;
if (!g_regex_match_full if (!g_regex_match_full (regex, search_str->str, search_str->len, 0, G_REGEX_MATCH_NEWLINE_ANY,
(regex, search_str->str, -1, 0, G_REGEX_MATCH_NEWLINE_ANY, &lc_mc_search->regex_match_info, &lc_mc_search->regex_match_info, &error))
&error))
{ {
g_match_info_free (lc_mc_search->regex_match_info); g_match_info_free (lc_mc_search->regex_match_info);
lc_mc_search->regex_match_info = NULL; lc_mc_search->regex_match_info = NULL;
@ -278,7 +277,7 @@ mc_search__regex_found_cond_one (mc_search_t * lc_mc_search, mc_search_regex_t *
lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info); lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info);
#else /* SEARCH_TYPE_GLIB */ #else /* SEARCH_TYPE_GLIB */
lc_mc_search->num_results = pcre_exec (regex, lc_mc_search->regex_match_info, lc_mc_search->num_results = pcre_exec (regex, lc_mc_search->regex_match_info,
search_str->str, search_str->len - 1, 0, 0, search_str->str, search_str->len, 0, 0,
lc_mc_search->iovector, MC_SEARCH__NUM_REPLACE_ARGS); lc_mc_search->iovector, MC_SEARCH__NUM_REPLACE_ARGS);
if (lc_mc_search->num_results < 0) if (lc_mc_search->num_results < 0)
{ {
@ -827,13 +826,8 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
g_string_append_c (lc_mc_search->regex_buffer, (char) current_chr); g_string_append_c (lc_mc_search->regex_buffer, (char) current_chr);
if ((char) current_chr == '\n' || virtual_pos > end_search)
if (current_chr == 0 || (char) current_chr == '\n')
break; break;
if (virtual_pos > end_search)
break;
} }
switch (mc_search__regex_found_cond (lc_mc_search, lc_mc_search->regex_buffer)) switch (mc_search__regex_found_cond (lc_mc_search, lc_mc_search->regex_buffer))
{ {