Changeset 783 for trunk


Ignore:
Timestamp:
Mar 6, 2023 8:19:20 PM (14 months ago)
Author:
anonymous
Message:

Rename function. Minor fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r781 r783  
    10171017* @since    09 Jun 2022 07:50:49
    10181018*/
    1019 function base64_encode_url($string) {
     1019function base64EncodeURL($string) {
    10201020    return str_replace(['+','/','='], ['-','_',''], base64_encode($string));
    10211021}
    1022 function base64_decode_url($string) {
     1022function base64DecodeURL($string) {
    10231023    return base64_decode(str_replace(['-','_'], ['+','/'], $string));
    10241024}
     
    13731373function verifySignature($signed_val, $salt=null, $length=18)
    13741374{
     1375    $app =& App::getInstance();
     1376
    13751377    // Strip the value from the signed value.
    13761378    $val = removeSignature($signed_val);
     1379    if ('' == $val) {
     1380        // Removing the signature failed because it was empty or did not contain a hyphen.
     1381        $app->logMsg(sprintf('Invalid signature ("%s" is not a valid signed value).', $signed_val), LOG_DEBUG, __FILE__, __LINE__);
     1382        return false;
     1383    }
    13771384    // If the signed value matches the original signed value we consider the value safe.
    13781385    if ('' != $signed_val && $signed_val == addSignature($val, $salt, $length)) {
     
    13801387        return true;
    13811388    } else {
    1382         $app =& App::getInstance();
    13831389        // A signature mismatch might occur if the signing_key is not the same across all environments, apache, cli, etc.
    1384         $app->logMsg(sprintf('Failed signature (%s should be %s).', $signed_val, addSignature($val, $salt, $length)), LOG_DEBUG, __FILE__, __LINE__);
     1390        $app->logMsg(sprintf('Invalid signature (%s should be %s).', $signed_val, addSignature($val, $salt, $length)), LOG_DEBUG, __FILE__, __LINE__);
    13851391        return false;
    13861392    }
     
    14431449    if (!isset($_SERVER['REMOTE_ADDR'])) {
    14441450        // In some cases this won't be set, e.g., CLI scripts.
    1445         return null;
     1451        return '';
    14461452    }
    14471453
Note: See TracChangeset for help on using the changeset viewer.