SiT! Bugs - SiT!
View Issue Details
0000757SiT!incidentspublic2009-07-03 09:582009-08-16 14:38
kieran 
kieran 
highblockhave not tried
closedfixed 
 
3.503.50 
0000757: Attachment paths wrong sometimes
If you upload a file via the update page, the link to view the file is missing (in my case), the 'localhost' part of the URL.
No tags attached.
Issue History
2009-07-03 09:58kieranNew Issue
2009-07-03 19:24paulhNote Added: 0001258
2009-07-03 19:24paulhStatusnew => confirmed
2009-07-03 19:28paulhNote Added: 0001259
2009-07-03 19:38paulhNote Added: 0001260
2009-07-03 19:38paulhPrioritynormal => high
2009-07-03 19:38paulhSeverityminor => block
2009-07-10 20:12paulhNote Added: 0001273
2009-07-12 20:24paulhNote Added: 0001306
2009-07-12 21:39kieranNote Added: 0001308
2009-07-12 21:39kieranStatusconfirmed => resolved
2009-07-12 21:39kieranFixed in Version => Current SVN
2009-07-12 21:39kieranResolutionopen => fixed
2009-07-12 21:39kieranAssigned To => kieran
2009-08-16 13:16ivanFixed in VersionCurrent SVN => 3.50
2009-08-16 14:38ivanNote Added: 0001631
2009-08-16 14:38ivanStatusresolved => closed

Notes
(0001258)
paulh   
2009-07-03 19:24   
Reproduced this here
(0001259)
paulh   
2009-07-03 19:28   
If you upload a file by the file page as well you have the same problem

You also get the problem when emailing

Suspect its a problem with the incident_log not expanding the URL properly
(0001260)
paulh   
2009-07-03 19:38   
I think the bbcode for [att] needs to include the server address.

Raising the priority and status of this bug
(0001273)
paulh   
2009-07-10 20:12   
For some reason incident_details.php has the following section of code duplicated

    $quote[0] = "/^(>([\s][\d\w]).*)[\n\r]$/m";
    $quote[1] = "/^(>>([\s][\d\w]).*)[\n\r]$/m";
    $quote[2] = "/^(>>>+([\s][\d\w]).*)[\n\r]$/m";
    $quote[3] = "/^(>>>(>)+([\s][\d\w]).*)[\n\r]$/m";
    $quote[4] = "/(-----\s?Original Message\s?-----.*-{3,})/s";
    $quote[5] = "/(-----BEGIN PGP SIGNED MESSAGE-----)/s";
    $quote[6] = "/(-----BEGIN PGP SIGNATURE-----.*-----END PGP SIGNATURE-----)/s";
    $quote[7] = "/^(>)[\r]*$/m";
    $quote[8] = "/^(>>)[\r]*$/m";
    $quote[9] = "/^(>>(>){1,8})[\r]*$/m";

    $quotereplace[0] = "<span class='quote1'>\\1</span>";
    $quotereplace[1] = "<span class='quote2'>\\1</span>";
    $quotereplace[2] = "<span class='quote3'>\\1</span>";
    $quotereplace[3] = "<span class='quote4'>\\1</span>";
    $quotereplace[4] = "<span class='quoteirrel'>\\1</span>";
    $quotereplace[5] = "<span class='quoteirrel'>\\1</span>";
    $quotereplace[6] = "<span class='quoteirrel'>\\1</span>";
    $quotereplace[7] = "<span class='quote1'>\\1</span>";
    $quotereplace[8] = "<span class='quote2'>\\1</span>";
    $quotereplace[9] = "<span class='quote3'>\\1</span>";

    $updatebody = preg_replace($quote, $quotereplace, $updatebody);

    // Make URL's into Hyperlinks
    /* This breaks BBCode by replacing URls in a tags PH 19/10/2008
    $search = array("/(?<!quot;|[=\"]|:[\\n]\/{2})\b((\w+:\/{2}|www\.).+?)"."(?=\W*([<>\s]|$))/i");
    $replace = array("<a href=\"\\1\">\\1</a>");
    $updatebody = preg_replace ($search, $replace, $updatebody);
    */

    // [begin] Insert link for old-style attachments [[att]]file.ext[[/att]] format
    // This code is required to support attachments written prior to v3.35
    // Please don't remove without a plan for what to do about old-style
    // attachments. INL 14Dec08
    if (file_exists("{$CONFIG['attachment_fspath']}{$update->incidentid}/{$update->timestamp}"))
    {
        $attachment_webpath = "{$CONFIG['attachment_webpath']}{$update->incidentid}/{$update->timestamp}";
    }
    else
    {
        $attachment_webpath = "{$CONFIG['attachment_webpath']}updates/{$update->id}";
    }
    $updatebody = preg_replace("/\[\[att\]\](.*?)\[\[\/att\]\]/", "<a href = '{$attachment_webpath}/$1'>$1</a>", $updatebody);
    // [end] Insert link for old-style attachments [[att]]file.ext[[/att]] format

    $updatebody = preg_replace("/href=\"(?!http[s]?:\/\/)/", "href=\"http://", [^] $updatebody);
    $updatebody = bbcode($updatebody);
    $updatebody = preg_replace("!([\n\t ]+)(http[s]?:/{2}[\w\.]{2,}[/\w\-\.\?\&\=\#\$\%|;|\[|\]~:]*)!e", "'\\1<a href=\"\\2\" title=\"\\2\">'.(strlen('\\2')>=70 ? substr('\\2',0,70).'...':'\\2').'</a>'", $updatebody);

    // Make KB article references into a hyperlink
    $updatebody = preg_replace("/\b{$CONFIG['kb_id_prefix']}([0-9]{3,4})\b/", "<a href=\"kb_view_article.php?id=$1\" title=\"View KB Article $1\">$0</a>", $updatebody);


Which is causing the BBCode and hyperlinks to be expenaded twice it seems, if you disable the first bbcode call then this works fine.

Though we'd probably be better checking over this code and only doing the regex once
(0001306)
paulh   
2009-07-12 20:24   
I believe trunk r5516 resolves this, can people test
(0001308)
kieran   
2009-07-12 21:39   
That fixes it, cheers Paul.
(0001631)
ivan   
2009-08-16 14:38   
Released in 3.50rc1