Explorar o código

fix variable escaping

Sven Klemm %!s(int64=7) %!d(string=hai) anos
pai
achega
907e8fd77c
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      public/app/plugins/datasource/postgres/postgres_query.ts

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

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