[pcre] try to avoid null chars in log messages

pull/72/head
Timothy Stack 11 years ago
parent 8acba75862
commit e08b11ff3d

@ -53,6 +53,7 @@ void scrub_ansi_string(std::string &str, string_attrs_t &sa)
pcrepp & regex = ansi_regex();
pcre_input pi(str);
replace(str.begin(), str.end(), '\0', ' ');
while (regex.match(context, pi)) {
pcre_context::capture_t *caps = context.all();
struct line_range lr;

@ -204,8 +204,8 @@ public:
if (iter->c_begin == -1) {
return "";
}
return std::string(this->pi_string,
iter->c_begin,
return std::string(&this->pi_string[iter->c_begin],
0,
iter->length());
};

@ -97,5 +97,12 @@ int main(int argc, char *argv[])
assert(pi.get_substr(context["var1"]) == "123");
}
{
pcre_context::capture cap(1, 4);
pcre_input pi("\0foo", 0, 4);
assert("foo" == pi.get_substr(&cap));
}
return retval;
}

Loading…
Cancel
Save