Seite 1 von 1

[url=

Verfasst: 23.01.2008 23:40
von nickvergessen
Warum funktioniert eigentlich mit manchen Addressen der

Code: Alles auswählen

[url]http://[/url]
nicht?
Bsp: http://www.phpbb.de/viewtopic.php?p=948673#948673

Code: Alles auswählen

[url=http://www.gidian-gelände.de/Forum/phpBB3/portal.php?sid=b799b90f8487520b527f3ae6cfe3936f]Forum[/url]

Verfasst: 23.01.2008 23:45
von Pyramide
kellanved hat geschrieben:Das liegt daran, dass die bbcodes nunmehr eine Positivliste der erlaubten Zeichen nutzen, anstelle der alten Negativliste.
Die php regulären Ausrücke kennen aber Umlaute nicht als Wortzeichen. Für die deutsche Version sollte man u.U. die Positivliste erweitern; keine Ahnung.

Verfasst: 24.01.2008 20:25
von cYbercOsmOnauT
kellanved hat geschrieben:keine Ahnung.
:D:D

Es liegt einfach daran, das RegEx natürlich bei \w nur normale ASCII-Zeichen (im 7Bit Bereich) als Buchstaben erkennt. Die Umlaute sind für ihn Sonderzeichen und keine Buchstaben. Dies kann man jedoch einfach anpassen.

bbcode.php im bbencode_second_pass
Ersetze

Code: Alles auswählen

	// matches a [url]xxxx://www.phpbb.com[/url] code..
	$patterns[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url1'];

	// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url2'];

	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$patterns[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url3'];

	// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url4'];

	// [email]user@domain.tld[/email] code..
	$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
durch

Code: Alles auswählen

	// matches a [url]xxxx://www.phpbb.com[/url] code..
	$patterns[] = "#\[url\]([\w]+?://([\wäöüß\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url1'];

	// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url\]((www|ftp)\.([\wäöüß\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url2'];

	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$patterns[] = "#\[url=([\w]+?://[\wäöüß\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url3'];

	// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url=((www|ftp)\.[\wäöüß\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url4'];

	// [email]user@domain.tld[/email] code..
	$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\wäöüß\-]+\.([\wäöüß\-\.]+\.)?[\w]+)\[/email\]#si";
Das sollte das Problem bei allen [url]-BBCodes und beim [email] lösen. Fehlt nun noch das make_clickable.
Ersetze

Code: Alles auswählen

	// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
	// xxxx can only be alpha characters.
	// yyyy is anything up to the first space, newline, comma, double quote or <
	$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href="\\2" target="_blank">\\2</a>", $ret);

	// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
	// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
	// zzzz is optional.. will contain everything up to the first space, newline, 
	// comma, double quote or <.
	$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href="http://\\2" target="_blank">\\2</a>", $ret);

	// matches an email@domain type address at the start of a line, or after a space.
	// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
	$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href="mailto:\\2@\\3">\\2@\\3</a>", $ret);
durch

Code: Alles auswählen

	// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
	// xxxx can only be alpha characters.
	// yyyy is anything up to the first space, newline, comma, double quote or <
	$ret = preg_replace("#(^|[\n ])([\w]+?://[\wäöüß\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href="\\2" target="_blank">\\2</a>", $ret);

	// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
	// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
	// zzzz is optional.. will contain everything up to the first space, newline, 
	// comma, double quote or <.
	$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\wäöüß\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href="http://\\2" target="_blank">\\2</a>", $ret);

	// matches an email@domain type address at the start of a line, or after a space.
	// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
	$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\wäöüß\-]+\.([\wäöüß\-\.]+\.)*[\w]+)#i", "\\1<a href="mailto:\\2@\\3">\\2@\\3</a>", $ret);
Der aufmerksame Beobachter bemerkt, dass ich überall an den richtigen Stellen äöüß hinzugefügt habe. ;)
Ist zwar ungetestet, aber sollte m.W. funktionieren.

Grüße,
Tekin

Verfasst: 24.01.2008 20:51
von Pyramide
cYbercOsmOnauT hat geschrieben:
kellanved hat geschrieben:keine Ahnung.
:D:D
LOLOL ROOOFL es hat jemand "keine Ahnung" gesagt muharhar ist das lustig, ich kann nicht mehr!
[ externes Bild ]

Verfasst: 24.01.2008 20:55
von cYbercOsmOnauT
Schau Dir mein Posting nochmal an... Während Du replyed hast, hab ich mein Posting erheblich erweitert und die Lösung reingeschrieben.

Re: [url=

Verfasst: 26.04.2010 22:20
von regie 510
Hallöchen,

wow, das klappt bestens. Die Suchfunktion ist Gold wert :)