2 package IkiWiki
::Plugin
::embed
;
8 my $attribr=qr/[^<>"]+/;
10 # regexp matching known-safe html
13 <\s
*iframe\s
+width
="\d+"\s
+height
="\d+"\s
+frameborder
="$attribr"\s
+
14 scrolling
="$attribr"\s
+marginheight
="\d+"\s
+marginwidth
="\d+"\s
+
15 src
="http://maps.google.com/\?$attribr"\s
*>\s
*</iframe
>
20 <\s
*object\s
+width
="\d+"\s
+height
="\d+"\s
*>\s
*
21 <\s
*param\s
+name
="movie"\s
+value
="http://www.youtube.com/v/$attribr"\s
*>\s
*
23 <\s
*param\s
+name
="wmode"\s
+value
="transparent"\s
*>\s
*</param
>\s
*
24 <embed\s
+src
="http://www.youtube.com/v/$attribr"\s
+
25 type
="application/x-shockwave-flash"\s
+wmode
="transparent"\s
+
26 width
="\d+"\s
+height
="\d+"\s
*>\s
*</embed>\s*</object
>
31 <\s
*embed\s
+style
="\s*width:\d+px;\s+height:\d+px;\s*"\s
+id
="$attribr"\s
+
32 type
="application/x-shockwave-flash"\s
+
33 src
="http://video.google.com/googleplayer.swf\?$attribr"\s
+
34 flashvars
=""\s
*>\s
*</embed
>
39 <\s
*iframe\s
+src
="http://www.google.com/calendar/embed\?src=$attribr"\s
+
40 style
="\s*border-width:\d+\s*"\s
+width
="\d+"\s
+frameborder
="\d+"\s
*
41 height
="\d+"\s
*>\s
*</iframe
>
47 hook
(type
=> "getsetup", id
=> "embed", call
=> \
&getsetup
);
48 hook
(type
=> "filter", id
=> "embed", call
=> \
&filter
);
60 hook
(type
=> "format", id
=> "embed", call
=> \
&format
) unless @embedded;
61 push @embedded, shift;
62 return "<div class=\"embed$#embedded\"></div>";
67 $params{content
} =~ s/$safehtml/embed($1)/eg;
68 return $params{content
};
73 $params{content
} =~ s/<div class="embed(\d+)"><\/div>/$embedded[$1]/eg
;
74 return $params{content
};