public inbox for [email protected]  
help / color / mirror / Atom feed
From: Neel Patel <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][patch]: String evaluation issue
Date: Mon, 18 Apr 2016 15:21:18 +0530
Message-ID: <CACCA4P3b2MskMggrE=GiL5_MNhGPfaMr1u1u-XvsYHvNOuF+aA@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

Please find attached patch file containing the fix for the below issue.
This issue is reported by Dave during the debugger code review and we have
removed the same issue from other files where we used.

*Issue :- *

When we use below string to form the error message then it will not work
because Jinja will evaluate the string " + err.errormsg + " before it gets
evaluated as JS by the browser.

           *alertify.error("{{ _('" + err.errormsg + "') }}");*


Do review it and let us know for any comments.

Thanks,
Neel Patel


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] string_evaluate.patch (3.9K, 3-string_evaluate.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/js/casts.js b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/js/casts.js
index 690a6d5..0ec6ffe 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/js/casts.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/js/casts.js
@@ -211,8 +211,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
                    try {
                      var err = $.parseJSON(xhr.responseText);
                      if (err.success == 0) {
-                       msg = S('{{ _(' + err.errormsg + ')}}').value();
-                       alertify.error("{{ _('" + err.errormsg + "') }}");
+                       alertify.error(err.errormsg);
                      }
                    } catch (e) {}
                  }
@@ -306,4 +305,4 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 
   }
     return pgBrowser.Nodes['coll-cast'];
-});
\ No newline at end of file
+});
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index a6bfb90..0408a52 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -151,13 +151,18 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
                     t.unload(i);
                     t.setInode(i);
                   }
+                  else {
+                    try {
+                      Alertify.error(res.errormsg);
+                    } catch (e) {}
+                    t.unload(i);
+                  }
                 },
                 error: function(xhr, status, error) {
                   try {
                     var err = $.parseJSON(xhr.responseText);
                     if (err.success == 0) {
-                      msg = S('{{ _(' + err.errormsg + ')}}').value();
-                      Alertify.error("{{ _('" + err.errormsg + "') }}");
+                      Alertify.error(err.errormsg);
                     }
                   } catch (e) {}
                   t.unload(i);
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index f7e093b..5423e98 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -87,7 +87,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
                 type:'DELETE',
                 success: function(res) {
                   if (res.success == 1) {
-                    alertify.success("{{ _('" + res.info + "') }}");
+                    alertify.success(res.info);
                     d = t.itemData(i);
                     t.removeIcon(i);
                     d.connected = false;
@@ -99,13 +99,18 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
                     }
                     obj.trigger('server-disconnected', obj, i, d);
                   }
+                  else {
+                    try {
+                        alertify.error(res.errormsg);
+                    } catch (e) {}
+                    t.unload(i);
+                  }
                 },
                 error: function(xhr, status, error) {
                   try {
                     var err = $.parseJSON(xhr.responseText);
                     if (err.success == 0) {
-                      msg = S('{{ _(' + err.errormsg + ')}}').value();
-                      alertify.error("{{ _('" + err.errormsg + "') }}");
+                      alertify.error(err.errormsg);
                     }
                   } catch (e) {}
                   t.unload(i);


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][patch]: String evaluation issue
  In-Reply-To: <CACCA4P3b2MskMggrE=GiL5_MNhGPfaMr1u1u-XvsYHvNOuF+aA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox