For more information... RTFM!
NAVIGATION
RECENTLY VIEWED
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

linkdecode

Decode certain hex-encoded values, so that if you have a HTML editor that encodes Interchange [area] tags (etc.), the editor won't destroy the edited HTML.

The filter is called "linkdecode" because it only operates on "<form action>", "href" and "src" parameter values.  It is therefore only useful when passed text containing HTML links and other URI references in the HTML.

Example

[filter linkdecode]<a href="%5barea href='foo'%5d">Click here</a>[/filter]

Results in:

<a href="http://www.example.com/foo.html">Click here</a>

Source code

sub {
    my $body = shift;
    $body =~ s{(<form\s+[^>]*action=)(["'])(\%5b\w+.*?\%5d)\2}
        { $1 . $2 . unhexify($3) . $2 }egi
;
    $body =~ s{(<\w+\s+[^>]*href=)(["'])(\%5b\w+.*?\%5d)\2}
        { $1 . $2 . unhexify($3) . $2 }egi
;
    $body =~ s{(<i\w+\s+[^>]*src=)(["'])(\%5b\w+.*?\%5d)\2}
        { $1 . $2 . unhexify($3) . $2 }egi
;
    return $body;
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Friday 23 February 2007 at 6:25 PM (EST)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us