Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made encodeAmpsAndAngles not try anymore to see if `<` is part of tag…

…s or not.

(This is no longer needed since all tags are "hashed".)
  • Loading branch information...
commit a98a3aa137797cbf7a060fbfd4a0777b85fe3f9b 1 parent 947cb24
@michelf authored
Showing with 12 additions and 11 deletions.
  1. +12 −11 markdown.php
View
23 markdown.php
@@ -1255,20 +1255,21 @@ function encodeAttribute($text) {
function encodeAmpsAndAngles($text) {
- # Smart processing for ampersands and angle brackets that need to be encoded.
+ #
+ # Smart processing for ampersands and angle brackets that need to
+ # be encoded. Valid character entities are left alone unless the
+ # no-entities mode is set.
+ #
if ($this->no_entities) {
$text = str_replace('&', '&amp;', $text);
- $text = str_replace('<', '&lt;', $text);
- return $text;
+ } else {
+ # Ampersand-encoding based entirely on Nat Irons's Amputator
+ # MT plugin: <http://bumppo.net/projects/amputator/>
+ $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
+ '&amp;', $text);;
}
-
- # Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
- # http://bumppo.net/projects/amputator/
- $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
- '&amp;', $text);;
-
- # Encode naked <'s
- $text = preg_replace('{<(?![a-z/?\$!%])}i', '&lt;', $text);
+ # Encode remaining <'s
+ $text = str_replace('<', '&lt;', $text);
return $text;
}
Please sign in to comment.
Something went wrong with that request. Please try again.