Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php final class PhabricatorWildConfigType extends PhabricatorJSONConfigType { cons..

Decoded Output download

<?php

final class PhabricatorWildConfigType
  extends PhabricatorJSONConfigType {

  const TYPEKEY = 'wild';

  protected function newCanonicalValue(
    PhabricatorConfigOption $option,
    $value) {

    $raw_value = $value;

    // NOTE: We're significantly more liberal about canonicalizing "wild"
    // values than "JSON" values because they're used to deal with some
    // unusual edge cases, including situations where old config has been left
    // in the database and we aren't sure what type it's supposed to be.
    // Accept anything we can decode.

    $value = json_decode($raw_value, true);
    if ($value === null && $raw_value != 'null') {
      throw $this->newException(
        pht(
          'Value for option "%s" (of type "%s") must be specified in JSON, '.
          'but input could not be decoded. (Did you forget to quote a string?)',
          $option->getKey(),
          $this->getTypeKey()));
    }

    return $value;
  }

  public function validateStoredValue(
    PhabricatorConfigOption $option,
    $value) {
    return;
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

final class PhabricatorWildConfigType
  extends PhabricatorJSONConfigType {

  const TYPEKEY = 'wild';

  protected function newCanonicalValue(
    PhabricatorConfigOption $option,
    $value) {

    $raw_value = $value;

    // NOTE: We're significantly more liberal about canonicalizing "wild"
    // values than "JSON" values because they're used to deal with some
    // unusual edge cases, including situations where old config has been left
    // in the database and we aren't sure what type it's supposed to be.
    // Accept anything we can decode.

    $value = json_decode($raw_value, true);
    if ($value === null && $raw_value != 'null') {
      throw $this->newException(
        pht(
          'Value for option "%s" (of type "%s") must be specified in JSON, '.
          'but input could not be decoded. (Did you forget to quote a string?)',
          $option->getKey(),
          $this->getTypeKey()));
    }

    return $value;
  }

  public function validateStoredValue(
    PhabricatorConfigOption $option,
    $value) {
    return;
  }

}

Function Calls

None

Variables

None

Stats

MD5 1425ef8cd4d578c2e8bd45944a309073
Eval Count 0
Decode Time 103 ms