16 Replies Latest reply on Aug 14, 2015 7:47 AM by try67

    May security update (11.0.11) broke custom object prototype for toString and valueOf?

    scottm89866116

      Customers have noted that since updating their clients to Reader 11.0.11, certain form functionality has stopped working.  Best I can determine, it comes down to a change that results in objects not resolving to a number or string anymore when referenced in things such as a math expression.

       

      I created a PDF with just the following basic script to exhibit the problem, coded in the same manner as the code I'm troubleshooting.  (I am not a programmer, so it could be that this is an outdated manner or simply something is poor and just requires redesign, but I cannot determine that myself).

       

      --------------------------

      function ABC( val, max, min, type, code )

      {

        this.type = type;

        this.value = val;

        this.maximum = max;

        this.minimum = min;

        this.internal = code;

      }

       

      ABC.XYZ = function( n )

      {

        var ret = Number.NaN;

        if (typeof( n ) == "number" ) {

          ret = n;

        } else if (typeof( n ) == "string") {

          ret = parseFloat( n );

        }

        return new ABC( ret, null, null, "num" );

      }

       

      ABC.prototype.valueOf = function()

      {

        return this.value;

      }

       

      ABC.prototype.toString = function()

      {

        return this.value.toString();

      }

       

      console.show();

      var x = ABC.XYZ("100");

      console.println("object x is " + x);

      console.println("object x .value is " + x.value);

      console.println("object x prototype valueOf is " + x.valueOf());

      console.println("object x prototype toString is " + x.toString());

      --------------------------

       

      If I run this under 11.0.10, I get the following console output:

      object x is 100

      object x .value is 100

      object x prototype valueOf is 100

      object x prototype toString is 100

       

      If I run this under 11.0.11, I get the following console output:

      object x is [object Object]

      object x .value is 100

      object x prototype valueOf is [object Object]

      object x prototype toString is [object Object]

       

      Is this a bug, or is this not supposed to work in Acrobat/Reader anymore?  If the latter, what's the correct way to do this now?

       

      Thanks.