summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/cssparser.cc46
-rw-r--r--src/cssparser.hh1
3 files changed, 31 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index c63398c6..10964734 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ dillo-2.2 [??]
- Fix X11 coordinate overflows with huge borders.
- Improve CSS font parsing.
- Enable font face setting via <font> element.
+ - Ignore XML comment markers in CSS.
Patch: Johannes Hofmann
+- Cleaned up system includes in dpid directory.
- Fixed CustProgressBox() for systems without weak symbols.
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 1b575aec..5782925a 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -410,6 +410,28 @@ void CssParser::ungetChar()
bufptr--;
}
+/*
+ * Skip string str if it is found in the input buffer.
+ * If not wind back. The first char is passed as parameter c
+ * to avoid unnecessary getChar() / ungetChar() calls.
+ */
+inline bool CssParser::skipString(int c, const char *str)
+{
+ int n = 0;
+
+ while (str[n]) {
+ if (str[n] != c) {
+ while (n--)
+ ungetChar();
+ return false;
+ }
+ c = getChar();
+ n++;
+ }
+
+ return true;
+}
+
void CssParser::nextToken()
{
int c, c1, d, j;
@@ -419,26 +441,16 @@ void CssParser::nextToken()
ttype = CSS_TK_CHAR; /* init */
spaceSeparated = false;
- c = getChar();
-
while (true) {
- if (isspace(c)) { // ignore whitespace
+ c = getChar();
+ if (isspace(c)) { // ignore whitespace
spaceSeparated = true;
- c = getChar();
- } else if (c == '/') { // ignore comments
- d = getChar();
- if (d == '*') {
- c = getChar();
- d = getChar();
- while (d != EOF && (c != '*' || d != '/')) {
- c = d;
- d = getChar();
- }
+ } else if (skipString(c, "/*")) { // ignore comments
+ do {
c = getChar();
- } else {
- ungetChar();
- break;
- }
+ } while (! skipString(c, "*/"));
+ } else if (skipString(c, "<!--")) { // ignore XML comment markers
+ } else if (skipString(c, "-->")) {
} else {
break;
}
diff --git a/src/cssparser.hh b/src/cssparser.hh
index d6e54ec7..1e471c68 100644
--- a/src/cssparser.hh
+++ b/src/cssparser.hh
@@ -28,6 +28,7 @@ class CssParser {
int getChar();
void ungetChar();
void nextToken();
+ bool skipString(int c, const char *string);
bool tokenMatchesProperty(CssPropertyName prop, CssValueType * type);
bool parseValue(CssPropertyName prop, CssValueType type,
CssPropertyValue * val);