Menu

#425 escapeBytea returns "x" for blank strings

GIT
pending-fixed
Tables (62)
5
2014-07-18
2012-10-24
No

When selecting from a table with a bytea field, the field is automatically filled with a single "x" character, meaning you have to clear it before an actual selection will work.

The problem is a result of the call to pg_escape_bytea in Postgres::escapeBytea (classes/database/Postgres.php). For some reason, when pg_escape_bytea("") is called in this function, it returns "\\x".

The confusing part is that if I write a script that does nothing but print the output of pg_escape_bytea(""), it returns an empty string as expected. I haven't figured out what phpPgAdmin does to alter the behaviour of this function.

I'm currently using phpPgAdmin 5.0.3-1, PostgreSQL 9.1+129ubuntu1, Apache 2.2.22-1ubuntu1, and php 5.3.10-1ubuntu3.4 under Ubuntu 12.04.1 LTS.

Discussion

  • Rick Yorgason

    Rick Yorgason - 2012-10-24

    I just realized my first sentence might be confusing since I'm using the term 'field' in two different ways.

    What I meant to say is, if you have a table with a bytea field and try to use the 'Select' action on it (ie tables.php?action=confselectrows), it fills the textarea next to the bytea column with an 'x' character.

     
  • Robert Treat

    Robert Treat - 2012-11-23

    Well, afaict, the reason you end up with an "x" is that we are calling stripslashes as well. It's odd that your test script produces an empty string, it should return \x I would think. In any case, fixing the above seems straightforward enough. I have a patch committed in my working tree:
    https://github.com/xzilla/phppgadmin/commit/00ba6912c15e04221e15574072449051af645685

    Please take a look and LMK if you have any problems with this. I'll probably merge it into upstream in a few days, though I think there are some additional escaping problems you should watch out for (that deal with 9.1's new escape format, which is incompatible with PPA's escape handling).

     
  • Robert Treat

    Robert Treat - 2012-11-23
    • milestone: --> GIT
    • assigned_to: nobody --> xzilla
    • status: open --> pending-fixed
     
  • Simon Yang

    Simon Yang - 2014-07-18

    Is this being fixed in 5.1 or anywhere?

     

Log in to post a comment.