Forráskód Böngészése

fix variable escaping

Sven Klemm 7 éve
szülő
commit
907e8fd77c

+ 6 - 2
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -48,7 +48,11 @@ export default class PostgresQuery {
   }
   }
 
 
   quoteLiteral(value) {
   quoteLiteral(value) {
-    return "'" + value.replace("'", "''") + "'";
+    return "'" + this.escapeLiteral(value) + "'";
+  }
+
+  escapeLiteral(value) {
+    return value.replace("'", "''");
   }
   }
 
 
   hasTimeGroup() {
   hasTimeGroup() {
@@ -62,7 +66,7 @@ export default class PostgresQuery {
   interpolateQueryStr(value, variable, defaultFormatFn) {
   interpolateQueryStr(value, variable, defaultFormatFn) {
     // if no multi or include all do not regexEscape
     // if no multi or include all do not regexEscape
     if (!variable.multi && !variable.includeAll) {
     if (!variable.multi && !variable.includeAll) {
-      return value;
+      return this.escapeLiteral(value);
     }
     }
 
 
     if (typeof value === 'string') {
     if (typeof value === 'string') {