SiT! Bugs

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000757SiT!incidentspublic2009-07-03 09:582009-08-16 14:38
Reporterkieran 
Assigned Tokieran 
PriorityhighSeverityblockReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version3.50Fixed in Version3.50 
Summary0000757: Attachment paths wrong sometimes
DescriptionIf 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
User avatar (0001258)
paulh (administrator)
2009-07-03 19:24

Reproduced this here
User avatar (0001259)
paulh (administrator)
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
User avatar (0001260)
paulh (administrator)
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
User avatar (0001273)
paulh (administrator)
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
User avatar (0001306)
paulh (administrator)
2009-07-12 20:24

I believe trunk r5516 resolves this, can people test
User avatar (0001308)
kieran (administrator)
2009-07-12 21:39

That fixes it, cheers Paul.
User avatar (0001631)
ivan (administrator)
2009-08-16 14:38

Released in 3.50rc1

- Issue History
Date Modified Username Field Change
2009-07-03 09:58 kieran New Issue
2009-07-03 19:24 paulh Note Added: 0001258
2009-07-03 19:24 paulh Status new => confirmed
2009-07-03 19:28 paulh Note Added: 0001259
2009-07-03 19:38 paulh Note Added: 0001260
2009-07-03 19:38 paulh Priority normal => high
2009-07-03 19:38 paulh Severity minor => block
2009-07-10 20:12 paulh Note Added: 0001273
2009-07-12 20:24 paulh Note Added: 0001306
2009-07-12 21:39 kieran Note Added: 0001308
2009-07-12 21:39 kieran Status confirmed => resolved
2009-07-12 21:39 kieran Fixed in Version => Current SVN
2009-07-12 21:39 kieran Resolution open => fixed
2009-07-12 21:39 kieran Assigned To => kieran
2009-08-16 13:16 ivan Fixed in Version Current SVN => 3.50
2009-08-16 14:38 ivan Note Added: 0001631
2009-08-16 14:38 ivan Status resolved => closed


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker