|
Joined: Mar 2004
Posts: 118
Journeyman
|
Journeyman
Joined: Mar 2004
Posts: 118 |
Does anyone know why this URL is broken: Google
Kind regards, PaNTerSan
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
No quotes allowed - a security risk.
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
GoogleYou have to encode it so that the " marks get chnaged to " then it'll work.
|
|
|
|
Joined: Mar 2004
Posts: 118
Journeyman
|
Journeyman
Joined: Mar 2004
Posts: 118 |
[] JoshPet said:You have to encode it so that the " marks get chnaged to " then it'll work. [/] Whoa It does work How could this be done via "Convert www -> html" in ubbt.inc.php <br />$Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $Body);<br /> My knowledge of regular expressions is worse than my knowledge of ballet [] http://pages.prodigy.net/rogerlori1/emoticons/bigblush.gif[/]
Kind regards, PaNTerSan
|
|
|
|
Joined: Sep 2003
Posts: 488
Code Monkey
|
Code Monkey
Joined: Sep 2003
Posts: 488 |
|
|
|
|
Joined: Mar 2004
Posts: 118
Journeyman
|
Journeyman
Joined: Mar 2004
Posts: 118 |
Tnx You should update URL broken mod
Kind regards, PaNTerSan
|
|
|
|
Joined: Sep 2003
Posts: 488
Code Monkey
|
Code Monkey
Joined: Sep 2003
Posts: 488 |
Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-(
Another solution will have to be found after all. If I come up with one I'll post it here.
|
|
|
|
Joined: Mar 2004
Posts: 118
Journeyman
|
Journeyman
Joined: Mar 2004
Posts: 118 |
[] Twisty said: Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-( [/] Well - it works fine without html After all if you are using html you could user <a href> [] Twisty said: Another solution will have to be found after all. If I come up with one I'll post it here. [/] Suit yourself I think you should repost the solution and make a note that if using html use <a href> ...
Last edited by PaNTerSan; 06/10/2004 9:09 AM.
Kind regards, PaNTerSan
|
|
|
|
Joined: Sep 2003
Posts: 488
Code Monkey
|
Code Monkey
Joined: Sep 2003
Posts: 488 |
Phew, ok I figured it out. Here's how (I have coded in alternative security measures on my own boards so that this doesn't pose a problem btw - see my other mod right here). In ubbt.inc.php... 1-A) CHANGE THIS: // -----------------------------------------------------------------<br /> // Make sure we don't get any quotes in our urls. Javascript is bad<br /> preg_match_all("/\[url=(.*?)\]/is",$Body,$matches1);<br /> $bad = "";<br /> for ($i=0; $i < count($matches1['0']); $i++) {<br /> if (strstr($matches1['0'][$i],"\"")) {<br /> $bad = 1;<br /> }<br /> }<br /> if (!$bad) {<br /> $Body = preg_replace("/\[url=http:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$Body);<br /> $Body = preg_replace("/\[url=https:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=\"https://\\1\" target=\"_blank\">\\2</a>",$Body);<br /> $Body = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$Body);<br /> }<br /> TO THIS: $Body = preg_replace("/\[url=http:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=http://\\1 target=_blank>\\2</a>",$Body);<br /> $Body = preg_replace("/\[url=https:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=https://\\1 target=_blank>\\2</a>",$Body);<br /> $Body = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i","<a href=http://\\1 target=_blank>\\2</a>",$Body); 1-B) CHANGE THIS: // ---------------------------<br /> // Convert www -> html<br /> $Body = " " . $Body;<br /> $Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $Body);<br /> $Body = preg_replace("#([\n\r ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $Body);<br /> $Body = preg_replace("#([\n\r ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $Body);<br /> $Body = substr($Body, 1);<br /> TO THIS: // ---------------------------<br /> // Convert www -> html<br /> $Body = " " . $Body;<br /> $Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i", "\\1<a href=\\2://\\3 target=_blank>\\2://\\3</a>", $Body);<br /> $Body = preg_replace("#([\n\r ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<a href=http://www.\\2.\\3\\4 target=_blank>www.\\2.\\3\\4</a>", $Body);<br /> $Body = preg_replace("#([\n\r ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $Body);<br /> $Body = substr($Body, 1);<br /> That's some real nasty hacking, but it does the job brilliantly NOTE: If you have Joshpet's short URL mod installed, then do the following in ubbt.inc.php as well... CHANGE THIS: // ---------------------------------------------------------<br /> // Truncate the URL if it's too long - by JoshPet & Gardener<br /> preg_match_all("/<a href=(\"|")([^\">]*?)(\"|")([^>]*?)>([^<]*?)<\/a>/i", $Body, $urlmatches, PREG_SET_ORDER);<br /> $matchcount = count($urlmatches);<br /> if ($matchcount) {<br /> for ($i = 0; $i<$matchcount; $i++) {<br /> $shorturl = $urlmatches[$i][5];<br /> if ((preg_match("#^(http|https|ftp)://#i",$shorturl)) && (strlen($shorturl) > 100)) {<br /> $shortenedurl = substr($shorturl, 0, 40) . "..." . substr($shorturl, -15);<br /> $shorturl = preg_quote($shorturl, "#");<br /> $Body = preg_replace("#>$shorturl</a>#i", ">$shortenedurl</a>", $Body, 1); <br /> }<br /> }<br /> } TO THIS: // ---------------------------------------------------------<br /> // Truncate the URL if it's too long - by JoshPet & Gardener<br /> preg_match_all("/<a href=([^\">]*?)([^>]*?)>([^<]*?)<\/a>/i", $Body, $urlmatches, PREG_SET_ORDER);<br /> $matchcount = count($urlmatches);<br /> if ($matchcount) {<br /> for ($i = 0; $i<$matchcount; $i++) {<br /> $shorturl = $urlmatches[$i][3];<br /> if ((preg_match("#^(http|https|ftp)://#i",$shorturl)) && (strlen($shorturl) > 100)) {<br /> $shortenedurl = substr($shorturl, 0, 40) . "..." . substr($shorturl, -15);<br /> $shorturl = preg_quote($shorturl, "#");<br /> $Body = preg_replace("#>$shorturl</a>#i", ">$shortenedurl</a>", $Body, 1); <br /> }<br /> }<br /> }<br /> Take it for a test drive and lemme know what you think.
|
|
|
|
Joined: Sep 2003
Posts: 488
Code Monkey
|
Code Monkey
Joined: Sep 2003
Posts: 488 |
[] PaNTerSan said: [] Twisty said: Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-( [/] Well - it works fine without html After all if you are using html you could user <a href> [] Twisty said: Another solution will have to be found after all. If I come up with one I'll post it here. [/] Suit yourself I think you should repost the solution and make a note that if using html use <a href> ... [/] Ohh I have a much, much better solution now which is compatible with anything See my post above. Try the new one out. I did a lot of testing with it and can't find any bugs.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 808
Joined: July 2001
|
|
Forums63
Topics37,573
Posts293,925
Members13,849
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|