public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][patch]: String evaluation issue
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][patch]: String evaluation issue
@ 2016-04-18 09:51 Neel Patel <[email protected]>
  2016-04-18 12:39 ` Re: [pgAdmin4][patch]: String evaluation issue Dave Page <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Neel Patel @ 2016-04-18 09:51 UTC (permalink / raw)
  To: pgadmin-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);


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin4][patch]: String evaluation issue
  2016-04-18 09:51 [pgAdmin4][patch]: String evaluation issue Neel Patel <[email protected]>
@ 2016-04-18 12:39 ` Dave Page <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2016-04-18 12:39 UTC (permalink / raw)
  To: Neel Patel <[email protected]>; +Cc: pgadmin-hackers

Thanks, applied.

On Monday, April 18, 2016, Neel Patel <[email protected]> wrote:

> 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
>
>

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-04-18 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-04-18 09:51 [pgAdmin4][patch]: String evaluation issue Neel Patel <[email protected]>
2016-04-18 12:39 ` Dave Page <[email protected]>

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