Plugin Directory


Ignore:
Timestamp:
11/13/2026 06:38:04 AM (40 hours ago)
Author:
gatecraftjp
Message:

2026.1.3.12: security and reliability improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gatecraft/trunk/includes/helpers.php

    r3797341 r3799773  
    687687}
    688688
     689/**
     690 * Unlisted events are reached only by their address, so the address must not be guessable from the title.
     691 * event_private_slug() ends it with 12 random hex characters (48 bits); event_slug_base() removes that part again,
     692 * so a copy of an unlisted event never carries the original's private part.
     693 */
     694function event_slug_base(string $slug): string
     695{
     696    return (string)preg_replace('/-[a-f0-9]{12}$/', '', $slug);
     697}
     698
     699function event_private_slug(string $slug): string
     700{
     701    if (preg_match('/-[a-f0-9]{12}$/', $slug)) return $slug;
     702    return rtrim(substr($slug, 0, 100), '-') . '-' . bin2hex(random_bytes(6));
     703}
     704
    689705/** Crockford base32 (no I, L, O, U): readable, unambiguous codes. */
    690706function random_code(int $len): string
Note: See TracChangeset for help on using the changeset viewer.