XMLLib.escapeXMLAttribute is required to add " arround the text to simplify code generation.

This commit is contained in:
igor%mir2.org 2004-09-10 17:40:59 +00:00
Родитель 00751b6a4f
Коммит 8bbc783f57
3 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -468,7 +468,7 @@ public class Parser
// 2. Functions defined under the with statement also immune to
// this setup, in which case dynamic scope is ignored in favor
// of with object.
fnNode.setIgnoreDynamicScope();
fnNode.itsIgnoreDynamicScope = true;
}
int functionIndex = currentScriptOrFn.addFunction(fnNode);
@ -1550,15 +1550,14 @@ public class Parser
} else {
pn = nf.createBinary(Token.ADD, pn, nf.createString(xml));
}
int nodeType;
if (ts.isXMLAttribute()) {
pn = nf.createBinary(Token.ADD, pn, nf.createString("\""));
expr = nf.createUnary(Token.ESCXMLATTR, expr);
pn = nf.createBinary(Token.ADD, pn, expr);
pn = nf.createBinary(Token.ADD, pn, nf.createString("\""));
nodeType = Token.ESCXMLATTR;
} else {
expr = nf.createUnary(Token.ESCXMLTEXT, expr);
pn = nf.createBinary(Token.ADD, pn, expr);
nodeType = Token.ESCXMLTEXT;
}
expr = nf.createUnary(nodeType, expr);
pn = nf.createBinary(Token.ADD, pn, expr);
break;
case Token.XMLEND:
xml = ts.getString();

Просмотреть файл

@ -91,6 +91,7 @@ public abstract class XMLLib
/**
* Escapes the reserved characters in a value of an attribute
* and surround it by "".
*
* @param value Unescaped text
* @return The escaped text

Просмотреть файл

@ -643,6 +643,7 @@ public final class XMLLibImpl extends XMLLib
/**
* Escapes the reserved characters in a value of an attribute
* and surround it by "".
*
* @param value Unescaped text
* @return The escaped text
@ -662,9 +663,9 @@ public final class XMLLibImpl extends XMLLib
cursor.dispose();
String elementText = xo.toString();
int begin = elementText.indexOf('"') + 1;
int begin = elementText.indexOf('"');
int end = elementText.lastIndexOf('"');
return (begin < end) ? elementText.substring(begin, end) : "";
return elementText.substring(begin, end + 1);
}
/**