[gnome-games] Escape tag values, based on a patch by Ted Ying
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Escape tag values, based on a patch by Ted Ying
- Date: Fri, 1 Jul 2011 11:00:32 +0000 (UTC)
commit a59c50133304922cff6d3598d5afd6185f45d280
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jul 1 11:58:03 2011 +0100
Escape tag values, based on a patch by Ted Ying
glchess/src/chess-pgn.vala | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/glchess/src/chess-pgn.vala b/glchess/src/chess-pgn.vala
index ee02c65..7cf025d 100644
--- a/glchess/src/chess-pgn.vala
+++ b/glchess/src/chess-pgn.vala
@@ -132,15 +132,20 @@ public class PGNGame
tags.insert ("Result", PGNGame.RESULT_IN_PROGRESS);
}
+ public string escape (string value)
+ {
+ var a = value.replace ("\\", "\\\\");
+ return a.replace ("\"", "\\\"");
+ }
+
public void write (File file) throws Error
{
var data = new StringBuilder ();
- // FIXME: Escape \ and " in tag values
var keys = tags.get_keys ();
keys.sort ((CompareFunc) compare_tag);
foreach (var key in keys)
- data.append ("[%s \"%s\"]\n".printf (key, tags.lookup (key)));
+ data.append ("[%s \"%s\"]\n".printf (key, escape (tags.lookup (key))));
data.append ("\n");
int i = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]