Wednesday, 15 June 2011

htmlpurifier add missing url protocol -



htmlpurifier add missing url protocol -

using autoformat.linkify htmlpurifier converts text such http://www.example.com into links. many people write links without protocol, such www.example.com or example.com. there anyway utilize htmlpurifier convert these links?

i know no way htmlpurifier this. should work adding http:// every link, not containing it. can utilize regular look this.

preg_replace( '#\s((https?|ftp)\:\/\/)?([a-z0-9-.]*)\.([a-z]{2,4})\s#', ' http://${3}.${4} ', $html );

test regex here.

example:

test example.com test<br> test www.example.com test<br> test http://example.com test

becomes

test http://example.com test test http://www.example.com test test http://example.com test

now htmlpurifier should right things.

htmlpurifier

No comments:

Post a Comment