Making WordPress.org

Changeset 12997


Ignore:
Timestamp:
12/04/2023 02:47:09 AM (3 months ago)
Author:
dd32
Message:

Helpscout: Match plugin emails when they're responses to translated emails, or using markedup hypens such as ndash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php

    r12996 r12997  
    266266 */
    267267function get_plugin_or_theme_from_email( $request, $validate_slugs = false ) {
    268     $subject  = $request->subject ?? ( $request->ticket->subject ?? '' );
    269     $email_id = $request->id      ?? ( $request->ticket->id      ?? 0 );
     268    $subject    = $request->subject   ?? ( $request->ticket->subject ?? '' );
     269    $email_id   = $request->id        ?? ( $request->ticket->id      ?? 0 );
     270    $mailbox_id = $request->mailboxId ?? ( $request->mailbox->id     ?? 0 );
    270271
    271272    $possible = [
     
    281282    /*
    282283     * Plugin reviews, match the format of either:
     284     *
    283285     * "[WordPress Plugin Directory] {Type Of Email}: {Plugin Title}"
    284286     * "[WordPress Plugin Directory] {Type Of Email} - {Plugin Title}"
     287     * "[Translated WordPress Plugin Directory] {Translated Type} - {Plugin Title}
     288     *
     289     * Because of translations, we can't be sure of the exact wording, so we'll just hope that it matches the general format.
     290     * NOTE: \p{Pd} is Regex for a dash-like character, which includes hyphens and ndashes.
    285291     */
    286292    if (
    287         preg_match( '!\[WordPress Plugin Directory\][^:]+: (?P<title>.+)$!i', $subject, $m ) ||
    288         preg_match( '!\[WordPress Plugin Directory\].+? - (?P<title>.+)$!i', $subject, $m )
     293        (
     294            'plugins' === get_mailbox_name( $mailbox_id ) &&
     295            (
     296                preg_match( '!\[[^]]+\][^:]+: (?P<title>.+)$!i', $subject, $m ) ||
     297                preg_match( '!\[[^]]+\].+? \p{Pd} (?P<title>.+)$!iu', $subject, $m )
     298            )
     299        ) || (
     300            // Same as above, but in non-plugins mailboxes using the English strings only.
     301            preg_match( '!\[WordPress Plugin Directory\][^:]+: (?P<title>.+)$!i', $subject, $m ) ||
     302            preg_match( '!\[WordPress Plugin Directory\].+? \p{Pd} (?P<title>.+)$!iu', $subject, $m )
     303        )
    289304    ) {
    290305        switch_to_blog( WPORG_PLUGIN_DIRECTORY_BLOGID );
Note: See TracChangeset for help on using the changeset viewer.