Skip to content
Browse files

Checking in Eloy's Javascript/smiley fixes from bug 1185 Thanks!

  • Loading branch information...
1 parent 9a11957 commit 8dcd43f3fed842e1f69c30dd374ac6f19a96e0a0 moodler committed Mar 25, 2004
Showing with 22 additions and 0 deletions.
  1. +22 −0 lib/weblib.php
View
22 lib/weblib.php
@@ -723,8 +723,30 @@ function replace_smilies(&$text) {
$runonce = true;
}
+ // Exclude from transformations all the code inside <script> tags
+ // Needed to solve Bug 1185. Thanks to jouse 2001 detecting it. :-)
+ // Based on code from glossary fiter by Williams Castillo.
+ // - Eloy
+
+ // Detect all the <script> zones to take out
+ $excludes = array();
+ preg_match_all('/<script language(.+?)<\/script>/is',$text,$list_of_excludes);
+
+ // Take out all the <script> zones from text
+ foreach (array_unique($list_of_excludes[0]) as $key=>$value) {
+ $excludes['<+'.$key.'+>'] = $value;
+ }
+ if ($excludes) {
+ $text = str_replace($excludes,array_keys($excludes),$text);
+ }
+
/// this is the meat of the code - this is run every time
$text = str_replace($e, $img, $text);
+
+ // Recover all the <script> zones to text
+ if ($excludes) {
+ $text = str_replace(array_keys($excludes),$excludes,$text);
+ }
}
function text_to_html($text, $smiley=true, $para=true, $newlines=true) {

0 comments on commit 8dcd43f

Please sign in to comment.
Something went wrong with that request. Please try again.