浏览代码

fix handling of QPair<QString, QString> in the reflection subsystem

The earlier code used comma as a separator and backslash for escaping,
which was neither tested or complete. Revamp it to use newline as the
separator, which should not need escaping as it is unlikely to be
present in the passed values. See #1944
Ashish Kulkarni 10 年之前
父节点
当前提交
eae59b40df
共有 1 个文件被更改,包括 6 次插入7 次删除
  1. 6 7
      src/lib/reflect.hh

+ 6 - 7
src/lib/reflect.hh

@@ -110,16 +110,15 @@ struct DLL_LOCAL ReflectImpl< QPair<QString, QString> >: public ReflectSimple {
 	ReflectImpl(QPair<QString, QString> & _): p(_) {};
 
 	QString get() {
-		return p.first.replace("\\", "\\\\").replace(",", "\\,") + "," +
-			p.second.replace("\\", "\\\\").replace(",", "\\,");
+		return p.first + "\n" + p.second;
 	}
 
 	void set(const QString & value, bool * ok) {
-		QStringList l = value.split(",");
-		if (l.size() != 0) {*ok=false; return;}
-		*ok=true;
-		p.first = l[0].replace("\\,",",").replace("\\\\","\\");
-		p.second = l[1].replace("\\,",",").replace("\\\\","\\");
+		QStringList l = value.split("\n");
+		if (l.size() != 2) {*ok=false; return;}
+		*ok      = true;
+		p.first  = l[0];
+		p.second = l[1];
 	}
 };