[gitg] Fix special '$' character in the diff view



commit 4cb6e32611664ed4d0421298701051f162ce0bf2
Author: Techlive Zheng <techlivezheng gmail com>
Date:   Sun Jun 16 22:39:00 2013 +0800

    Fix special '$' character in the diff view

 libgitg-gtk/resources/diff-view-html-builder.js |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/libgitg-gtk/resources/diff-view-html-builder.js b/libgitg-gtk/resources/diff-view-html-builder.js
index 3c30b64..cfd12c4 100644
--- a/libgitg-gtk/resources/diff-view-html-builder.js
+++ b/libgitg-gtk/resources/diff-view-html-builder.js
@@ -117,8 +117,14 @@ function diff_file(file, lnstate, data)
 
        for (var r in repls)
        {
-               log([template, lnstate.replacements[r], repls[r]]);
-               template = template.replace(lnstate.replacements[r], repls[r]);
+               // As we are using the repl in the later 'template.replace()'
+               // as the replacement in which character '$' is special, we
+               // need to make sure each occurence of '$' character in the
+               // replacement is represented as '$$' (which stands for a
+               // literal '$'), so, we need to use '$$$$' here to get '$$'.
+               var repl = repls[r].replace(/\$/g, '$$$$');
+               log([template, lnstate.replacements[r], repl]);
+               template = template.replace(lnstate.replacements[r], repl);
        }
 
        return template;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]