فهرست منبع

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];
 	}
 };