Fixed issues with HTML comments and Helma macros in Helma format functions.
This commit is contained in:
parent
1012b31a6a
commit
40ba46d788
1 changed files with 32 additions and 13 deletions
|
@ -253,7 +253,6 @@ public final class HtmlEncoder {
|
||||||
allTags.add ("var");
|
allTags.add ("var");
|
||||||
allTags.add ("wbr");
|
allTags.add ("wbr");
|
||||||
allTags.add ("xmp");
|
allTags.add ("xmp");
|
||||||
allTags.add ("%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tags which signal us to start suppressing \n -> <br> encoding
|
// tags which signal us to start suppressing \n -> <br> encoding
|
||||||
|
@ -304,6 +303,8 @@ public final class HtmlEncoder {
|
||||||
boolean insideCodeTag = false;
|
boolean insideCodeTag = false;
|
||||||
// are we within a macro tag?
|
// are we within a macro tag?
|
||||||
boolean insideMacroTag = false;
|
boolean insideMacroTag = false;
|
||||||
|
// are we inside an HTML comment?
|
||||||
|
boolean insideComment = false;
|
||||||
// the difference between swallowOneNewline and ignoreNewline is that
|
// the difference between swallowOneNewline and ignoreNewline is that
|
||||||
// swallowOneNewline is just effective once (for the next newline)
|
// swallowOneNewline is just effective once (for the next newline)
|
||||||
boolean ignoreNewline = false;
|
boolean ignoreNewline = false;
|
||||||
|
@ -346,10 +347,22 @@ public final class HtmlEncoder {
|
||||||
boolean insideCloseTag = ('/' == chars[i+1]);
|
boolean insideCloseTag = ('/' == chars[i+1]);
|
||||||
int tagStart = insideCloseTag ? i+2 : i+1;
|
int tagStart = insideCloseTag ? i+2 : i+1;
|
||||||
int j = tagStart;
|
int j = tagStart;
|
||||||
while (j<l && (Character.isLetterOrDigit (chars[j]) || chars[j] == '%'))
|
while (j<l && Character.isLetterOrDigit (chars[j]))
|
||||||
j++;
|
j++;
|
||||||
|
// if we haven't gotten past the <,
|
||||||
|
// check if it's an HTML comment or Helma macro tag
|
||||||
|
if (j == tagStart) {
|
||||||
|
if ('%' == chars[j]) {
|
||||||
|
insideMacroTag = insideTag = true;
|
||||||
|
ret.append ('<');
|
||||||
|
continue;
|
||||||
|
} else if (j < l-2 && '!' == chars[j] && '-' == chars[j+1] && '-' == chars[j+2]) {
|
||||||
|
insideComment = insideTag = true;
|
||||||
|
ret.append ('<');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (j > tagStart && j < l) {
|
if (j > tagStart && j < l) {
|
||||||
insideMacroTag = ('%' == chars[i+1]);
|
|
||||||
String tagName = new String (chars, tagStart, j-tagStart).toLowerCase ();
|
String tagName = new String (chars, tagStart, j-tagStart).toLowerCase ();
|
||||||
if ("code".equals (tagName) && insideCloseTag && insideCodeTag)
|
if ("code".equals (tagName) && insideCloseTag && insideCodeTag)
|
||||||
insideCodeTag = false;
|
insideCodeTag = false;
|
||||||
|
@ -385,11 +398,17 @@ public final class HtmlEncoder {
|
||||||
swallowOneNewline = false;
|
swallowOneNewline = false;
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
if (insideTag)
|
if (insideTag) {
|
||||||
ret.append ('>');
|
ret.append ('>');
|
||||||
|
if (insideMacroTag)
|
||||||
|
insideMacroTag = insideTag = !(chars[i-1] == '%');
|
||||||
|
else if (insideComment)
|
||||||
|
insideComment = insideTag = !(chars[i-2] == '-' && chars[i-1] == '-');
|
||||||
else
|
else
|
||||||
|
insideTag = false;
|
||||||
|
} else {
|
||||||
ret.append (">");
|
ret.append (">");
|
||||||
insideTag = insideMacroTag ? chars[i-1] != '%' : false;
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// ret.append (c);
|
// ret.append (c);
|
||||||
|
|
Loading…
Add table
Reference in a new issue