Heine

  • home
  • drupal
  • drupal core commits
  • about
Home › Drupal Core Commits

Commit 233180 by dries

- Patch #359276 by Freso, Heine, lyricnz: avoid double encoding/decoding of HTML entities.

--- includes/common.inc 2009/07/02 04:27:22     1.926
+++ includes/common.inc 2009/07/03 18:26:34     1.927
@@ -1359,12 +1359,12 @@
   // Defuse all HTML entities
   $string = str_replace('&', '&', $string);
   // Change back only well-formed entities in our whitelist
-  // Named entities
-  $string = preg_replace('/&([A-Za-z][A-Za-z0-9]*;)/', '&\1', $string);
   // Decimal numeric entities
   $string = preg_replace('/&#([0-9]+;)/', '&#\1', $string);
   // Hexadecimal numeric entities
   $string = preg_replace('/&#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/', '&#x\1', $string);
+  // Named entities
+  $string = preg_replace('/&([A-Za-z][A-Za-z0-9]*;)/', '&\1', $string);
 
   return preg_replace_callback('%
     (

--- modules/filter/filter.test  2009/06/28 18:03:56     1.25
+++ modules/filter/filter.test  2009/07/03 18:26:35     1.26
@@ -399,6 +399,15 @@
 
     $f = filter_xss("\xc0aaa");
     $this->assertEqual($f, '', t('HTML filter -- overlong UTF-8 sequences.'));
+
+    $f = filter_xss("Who's Online");
+    $this->assertNormalized($f, "who's online", t('HTML filter -- html entity number'));
+
+    $f = filter_xss("Who's Online");
+    $this->assertNormalized($f, "who's online", t('HTML filter -- encoded html entity number'));
+
+    $f = filter_xss("Who' Online");
+    $this->assertNormalized($f, "who' online", t('HTML filter -- double encoded html entity number'));
   }
 
   /**

No votes yet
  • Drupal Core
  • Download patch

Recent posts

  • The Joomlafication of the Dutch-speaking community
  • Upgraded from 6.14 to 6.15, but Drupal still thinks it's 6.14?
  • Google Friendconnect Drupal module not recommended (yet)
  • The OpenID 2.0 Compliance Crusade - Part I
  • Using <embed> for XSS
more

Security reviews

  • Afraid custom code makes your site vulnerable?
  • You don't really trust that module you just downloaded from Drupal.org?

Sleep better after a security review.

Tags

Captcha CSRF DOH! Drupal embed Input Format modx OpenID Performance Planet Drupal Security Varnish
more tags
  • home
  • drupal
  • drupal core commits
  • about

Copyright © 2010 by Heine Deelstra. All rights reserved.