[geary] Fix regex for restoring quotes in plain text construction
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix regex for restoring quotes in plain text construction
- Date: Fri, 7 Feb 2014 00:40:38 +0000 (UTC)
commit 8e283cc6b670806a954499a86d9fe0af9d23133b
Author: Robert Schroll <rschroll gmail com>
Date: Thu Feb 6 03:27:23 2014 -0500
Fix regex for restoring quotes in plain text construction
The character following the token is found through a look-ahead, to
avoid consuming the opening of the next token. (There should be
newlines separating tokens, but in some poorly understood circumstances,
this doesn't happen.) We don't use a look-behind at the beginning, so
that the second consecutive token doesn't insert a second newline
between the two. (The first of the pair already gave us one.)
Closes: bgo #723742
src/client/util/util-webkit.vala | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/client/util/util-webkit.vala b/src/client/util/util-webkit.vala
index 0d3c296..6ab1bfd 100644
--- a/src/client/util/util-webkit.vala
+++ b/src/client/util/util-webkit.vala
@@ -374,17 +374,17 @@ public string quote_lines(string text) {
public string resolve_nesting(string text, string[] values) {
try {
- GLib.Regex tokenregex = new GLib.Regex("(.?)([0-9]*)(.?)");
+ GLib.Regex tokenregex = new GLib.Regex("(.?)([0-9]*)(?=(.?))");
return tokenregex.replace_eval(text, -1, 0, 0, (info, res) => {
int key = int.parse(info.fetch(2));
- string prev_char = info.fetch(1), next_char = info.fetch(3);
+ string prev_char = info.fetch(1), next_char = info.fetch(3), insert_next = "";
// Make sure there's a newline before and after the quote.
if (prev_char != "" && prev_char != "\n")
prev_char = prev_char + "\n";
if (next_char != "" && next_char != "\n")
- next_char = "\n" + next_char;
+ insert_next = "\n";
if (key >= 0 && key < values.length) {
- res.append(prev_char + quote_lines(resolve_nesting(values[key], values)) + next_char);
+ res.append(prev_char + quote_lines(resolve_nesting(values[key], values)) + insert_next);
} else {
debug("Regex error in denesting blockquotes: Invalid key");
res.append("");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]