Plugin Directory

Changeset 3751269


Ignore:
Timestamp:
10/17/2026 12:04:52 AM (37 hours ago)
Author:
WayneAllen
Message:

Escape autolink href and title attributes to prevent XSS

Location:
postie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • postie/trunk/GEMINI.md

    r3707989 r3751269  
    136136    *   Run `deploy\deploy.cmd` (or `deploy/deploy.sh` on Unix-like environments) to automatically generate the `readme.txt` and build/package the release assets.
    1371375.  **Source Control**:
    138     *   Commit all finalized files locally: `git commit -am "Prepare <version> release"`
    139     *   Create a release tag: `git tag -a <version> -m "Release <version>"`
     138    *   Commit all finalized files: `svn commit -m "Prepare <version> release"`
     139    *   Create a release tag: `svn copy ^/postie/trunk ^/postie/tags/<version> -m "Release <version>"`
    1401406.  **Public Announcements**:
    141141    *   Add a release post on the official Postie site: `http://postieplugin.com/`
  • postie/trunk/lib/autolink.php

    r3708365 r3751269  
    148148                if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$°’;]+)/i', $post, $matches)) {
    149149
    150                     $url = $hit . $matches[1];
    151 
    152                     $cursor += strlen($url) + strlen($pre_hit);
     150                    $raw_url = $hit . $matches[1];
     151
     152                    $cursor += strlen($raw_url) + strlen($pre_hit);
    153153                    $buffer .= $pre_hit;
    154154
    155                     $url = html_entity_decode($url);
     155                    $url = html_entity_decode($raw_url);
     156
     157                    if (preg_match('/[\s<>"\\\\\x00-\x1f\x7f]/', $url)) {
     158                        $buffer .= $raw_url;
     159                        continue;
     160                    }
    156161
    157162                    #
    … …  
    202207                        if (!preg_match("!^(http|https)://{$display_quoted}$!i", $link_url)) {
    203208
    204                             $currentTagfill .= ' title="' . $link_url . '"';
     209                            $currentTagfill .= ' title="' . htmlspecialchars($link_url, ENT_QUOTES, 'UTF-8') . '"';
    205210                        }
    206211                    }
    … …  
    237242                        DebugEcho("autolink_do: linkifying $link_url");
    238243                        try {
    239                             $link_html = apply_filters('postie_bare_link', "<a href=\"{$link_url}\"$currentTagfill>{$display_url_enc}</a>", $link_url, false);
     244                            $link_html = apply_filters('postie_bare_link', "<a href=\"{$link_url_enc}\"$currentTagfill>{$display_url_enc}</a>", $link_url, false);
    240245                        } catch (Throwable $exc) {
    241246                            EchoError('postie_bare_link: ' . $exc->getMessage() . "\n" . $exc->getTraceAsString());
    … …  
    426431                $cursor += strlen($pre) + strlen($hit);
    427432                $buffer .= $pre;
    428                 $buffer .= "<a href=\"mailto:$hit\" $tagfill>$hit</a>";
     433                $hit_enc = htmlspecialchars($hit);
     434                $buffer .= "<a href=\"mailto:$hit_enc\" $tagfill>$hit_enc</a>";
    429435            }
    430436        }
Note: See TracChangeset for help on using the changeset viewer.