0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-23 00:41:52 +00:00

Fit everything to width=80.

git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@48 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-05-30 14:38:28 +00:00
parent e3c4faae41
commit 3f123d6f53

View File

@ -75,7 +75,14 @@ class HTML_Lexer
if (!$inside_tag && $position_next_lt !== false) { if (!$inside_tag && $position_next_lt !== false) {
// We are not inside tag and there still is another tag to parse // We are not inside tag and there still is another tag to parse
$array[] = new MF_Text(html_entity_decode(substr($string, $cursor, $position_next_lt - $cursor))); $array[] = new
MF_Text(
html_entity_decode(
substr(
$string, $cursor, $position_next_lt - $cursor
)
)
);
$cursor = $position_next_lt + 1; $cursor = $position_next_lt + 1;
$inside_tag = true; $inside_tag = true;
continue; continue;
@ -84,7 +91,14 @@ class HTML_Lexer
// If we're already at the end, break // If we're already at the end, break
if ($cursor === strlen($string)) break; if ($cursor === strlen($string)) break;
// Create Text of rest of string // Create Text of rest of string
$array[] = new MF_Text(html_entity_decode(substr($string, $cursor))); $array[] = new
MF_Text(
html_entity_decode(
substr(
$string, $cursor
)
)
);
break; break;
} elseif ($inside_tag && $position_next_gt !== false) { } elseif ($inside_tag && $position_next_gt !== false) {
// We are in tag and it is well formed // We are in tag and it is well formed
@ -92,8 +106,16 @@ class HTML_Lexer
$segment = substr($string, $cursor, $position_next_gt-$cursor); $segment = substr($string, $cursor, $position_next_gt-$cursor);
// Check if it's a comment // Check if it's a comment
if (substr($segment,0,3) == '!--' && substr($segment,strlen($segment)-2,2) == '--') { if (
$array[] = new MF_Comment(substr($segment,3,strlen($segment)-5)); substr($segment,0,3) == '!--' &&
substr($segment,strlen($segment)-2,2) == '--'
) {
$array[] = new
MF_Comment(
substr(
$segment, 3, strlen($segment) - 5
)
);
$inside_tag = false; $inside_tag = false;
$cursor = $position_next_gt + 1; $cursor = $position_next_gt + 1;
continue; continue;
@ -133,7 +155,12 @@ class HTML_Lexer
// Grab out all the data // Grab out all the data
$type = substr($segment, 0, $position_first_space); $type = substr($segment, 0, $position_first_space);
$attribute_string = trim(substr($segment, $position_first_space)); $attribute_string =
trim(
substr(
$segment, $position_first_space
)
);
$attributes = $this->tokenizeAttributeString($attribute_string); $attributes = $this->tokenizeAttributeString($attribute_string);
if ($is_self_closing) { if ($is_self_closing) {
$array[] = new MF_EmptyTag($type, $attributes); $array[] = new MF_EmptyTag($type, $attributes);
@ -144,7 +171,13 @@ class HTML_Lexer
$inside_tag = false; $inside_tag = false;
continue; continue;
} else { } else {
$array[] = new MF_Text('<' . html_entity_decode(substr($string, $cursor))); $array[] = new
MF_Text(
'<' .
html_entity_decode(
substr($string, $cursor)
)
);
break; break;
} }
break; break;
@ -189,7 +222,11 @@ class HTML_Lexer
$position_next_space === false)) { $position_next_space === false)) {
//attr="asdf" //attr="asdf"
// grab the key // grab the key
$key = trim(substr($string, $cursor, $position_next_equal - $cursor)); $key = trim(
substr(
$string, $cursor, $position_next_equal - $cursor
)
);
// set cursor right after the equal sign // set cursor right after the equal sign
$cursor = $position_next_equal + 1; $cursor = $position_next_equal + 1;
@ -223,7 +260,9 @@ class HTML_Lexer
// otherwise, regular attribute // otherwise, regular attribute
$quote = $string{$position_next_quote}; $quote = $string{$position_next_quote};
$position_end_quote = strpos($string, $quote, $position_next_quote + 1); $position_end_quote = strpos(
$string, $quote, $position_next_quote + 1
);
// check if the ending quote is missing // check if the ending quote is missing
if ($position_end_quote === false) { if ($position_end_quote === false) {