ThWboard Support-Forum (Archiv)

Ort: / Boardübersicht / Probleme und Fragen / Problem mit autom. URL-Parsing (thwb-2006-01-10-trunk)


Seite 1 von 1

fratzi schrieb am 29.08.2006 um 13:11 Uhr

Hallo,

ich nutze thwb-2006-01-10-trunk und habe das Problem, dass das automatische URL-Parsing nicht sauber funktioniert.

http://img138.imageshack.us/img138/746/urlmk5.jpg

Hier der Auszug aus der thwbcode.inc.php:

<?php
/* $Id: thwbcode.inc.php 346 2005-05-27 12:11:00Z td $ */

/**
 * formats a tag-enclosed string
 * 
 * @param    a        tag content
 * @param    b        tag parameter, if present
 * 
 * @return    string    HTML representation of string.    
 */

function format_url($a, $b = '')
{
    $l = trim(((empty($b)) ? $a : $b));

    // check url

    if(preg_match('/^(about|(java|vb)script):/i', $l))
    {
        return $l;
    }

    if(!preg_match('/^([a-zA-Z])([a-zA-Z0-9.\-+]+):\/\//', $l))
    {
        $l = 'http://'.$l;
    }

    return '<a href="'.$l.'" target="_blank">'.$a.'</a>';
}

/**
 * replaces non-tagged links with actual links
 * 
 * @param    str        string to format
 * 
 * @return    string    HTML representation of str
 */

function auto_links($str)
{   
    $a_search = array("/(?:(?<=^|>))([a-zA-Z])([a-zA-Z0-9.\-+]+):\/\/([^ \"\n<]+?)([\?!,\.\)]*)(?=[ \"\n\[<]|$)/e", 
                      "/(^|[\]\( \n])www\.([^ \"\n<]+?)([\?!,\.\)]*)(?=[ \"\n\[<]|$)/ie");
    $a_replace = array('format_url(\'\1\2://\3\').\'\4\'',
                       '\'\1\'.format_url(\'www.\2\').\'\3\'');
 
    return preg_replace($a_search, $a_replace, $str);
}

?>

Erkennt jemand den Fehler?

Seite 1 von 1