Plugin Directory

Changeset 3323146


Ignore:
Timestamp:
07/06/2025 09:07:50 PM (9 months ago)
Author:
rsnare
Message:

Updates for consistent multiturn responses (1.1.4)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dairect-chat/trunk/includes/api-handler.php

    r3322007 r3323146  
    1616  $api_key = getenv('GEMINI_API_KEY');
    1717
    18   // Line 19 over-sanitized for Plugin Review
    19   $session_raw = isset($_SESSION['dairect_chat_history'])
     18  // Properly sanitized session history
     19  $session_raw = isset($_SESSION['dairect_chat_history']) && is_array($_SESSION['dairect_chat_history'])
    2020    ? array_map(function($entry) {
    2121        return [
     
    2323          'parts' => array_map(function($part) {
    2424            return ['text' => sanitize_text_field(wp_unslash($part['text'] ?? ''))];
    25           }, wp_unslash($entry['parts'] ?? []))
     25          }, is_array($entry['parts'] ?? null) ? wp_unslash($entry['parts']) : [])
    2626        ];
    27       }, wp_unslash((array) sanitize_text_field(json_encode($_SESSION['dairect_chat_history'] ?? []))))
     27      }, wp_unslash($_SESSION['dairect_chat_history']))
    2828    : [];
    2929
    30   // Line 27 over-sanitized too
    3130  $firstMsg = isset($session_raw[0]['parts'][0]['text'])
    3231    ? sanitize_text_field($session_raw[0]['parts'][0]['text'])
Note: See TracChangeset for help on using the changeset viewer.