url_auto_link
안녕하세요 수고 많으십니다.
본문에 [http://domain.com/abc.gif] 가 있을 경우 auto_link 가 걸리는데..
링크에 특수문자 ] 가 포함되는 현상이 있습니다.
[<A HREF="http://domain.com/abc.gif]" TARGET='_blank'>http://domain.com/abc.gif]</A>
이렇게 되어야 하는데요..
[<A HREF="http://domain.com/abc.gif" TARGET='_blank'>http://domain.com/abc.gif</A>]
검토 부탁드립니다.
본문에 [http://domain.com/abc.gif] 가 있을 경우 auto_link 가 걸리는데..
링크에 특수문자 ] 가 포함되는 현상이 있습니다.
[<A HREF="http://domain.com/abc.gif]" TARGET='_blank'>http://domain.com/abc.gif]</A>
이렇게 되어야 하는데요..
[<A HREF="http://domain.com/abc.gif" TARGET='_blank'>http://domain.com/abc.gif</A>]
검토 부탁드립니다.
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 1개
[code]
function url_auto_link($str)
{
global $g5;
global $config;
// 140326 유창화님 제안코드로 수정
// http://sir.co.kr/bbs/board.php?bo_table=pg_lecture&wr_id=461
// http://sir.co.kr/bbs/board.php?bo_table=pg_lecture&wr_id=463
$str = str_replace(array("<", ">", "&", """, " ", "'"), array("\t_lt_\t", "\t_gt_\t", "&", "\"", "\t_nbsp_\t", "'"), $str);
//$str = preg_replace("`(?:(?:(?:href|src)\s*=\s*(?:\"|'|)){0})((http|https|ftp|telnet|news|mms)://[^\"'\s()]+)`", "<A HREF=\"\\1\" TARGET='{$config['cf_link_target']}'>\\1</A>", $str);
$str = preg_replace("/([^(href=\"?'?)|(src=\"?'?)]|\(|^)((http|https|ftp|telnet|news|mms):\/\/[a-zA-Z0-9\.-]+\.[가-힣\xA1-\xFEa-zA-Z0-9\.:=_\?\/~\+%@;\-\|\,\(\)]+)/i", "\\1<A HREF=\"\\2\" TARGET=\"{$config['cf_link_target']}\">\\2</A>", $str);
$str = preg_replace("/(^|[\"'\s(])(www\.[^\"'\s()]+)/i", "\\1<A HREF=\"http://\\2\" TARGET=\"{$config['cf_link_target']}\">\\2</A>", $str);
$str = preg_replace("/[0-9a-z_-]+@[a-z0-9._-]{4,}/i", "<a href=\"mailto:\\0\">\\0</a>", $str);
$str = str_replace(array("\t_nbsp_\t", "\t_lt_\t", "\t_gt_\t", "'"), array(" ", "<", ">", "'"), $str);
/*
// 속도 향상 031011
$str = preg_replace("/</", "\t_lt_\t", $str);
$str = preg_replace("/>/", "\t_gt_\t", $str);
$str = preg_replace("/&/", "&", $str);
$str = preg_replace("/"/", "\"", $str);
$str = preg_replace("/ /", "\t_nbsp_\t", $str);
$str = preg_replace("/([^(http:\/\/)]|\(|^)(www\.[^[:space:]]+)/i", "\\1<A HREF=\"http://\\2\" TARGET='{$config['cf_link_target']}'>\\2</A>", $str);
//$str = preg_replace("/([^(HREF=\"?'?)|(SRC=\"?'?)]|\(|^)((http|https|ftp|telnet|news|mms):\/\/[a-zA-Z0-9\.-]+\.[\xA1-\xFEa-zA-Z0-9\.:=_\?\/~\+%@;\-\|\,]+)/i", "\\1<A HREF=\"\\2\" TARGET='$config['cf_link_target']'>\\2</A>", $str);
// 100825 : () 추가
// 120315 : CHARSET 에 따라 링크시 글자 잘림 현상이 있어 수정
$str = preg_replace("/([^(HREF=\"?'?)|(SRC=\"?'?)]|\(|^)((http|https|ftp|telnet|news|mms):\/\/[a-zA-Z0-9\.-]+\.[가-힣\xA1-\xFEa-zA-Z0-9\.:=_\?\/~\+%@;\-\|\,\(\)]+)/i", "\\1<A HREF=\"\\2\" TARGET='{$config['cf_link_target']}'>\\2</A>", $str);
// 이메일 정규표현식 수정 061004
//$str = preg_replace("/(([a-z0-9_]|\-|\.)+@([^[:space:]]*)([[:alnum:]-]))/i", "<a href='mailto:\\1'>\\1</a>", $str);
$str = preg_replace("/([0-9a-z]([-_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,4})/i", "<a href='mailto:\\1'>\\1</a>", $str);
$str = preg_replace("/\t_nbsp_\t/", " " , $str);
$str = preg_replace("/\t_lt_\t/", "<", $str);
$str = preg_replace("/\t_gt_\t/", ">", $str);
*/
return $str;
}
[/code]
확인해 보시기 바랍니다.