зеркало из https://github.com/mozilla/pjs.git
XMLLib.escapeXMLAttribute is required to add " arround the text to simplify code generation.
This commit is contained in:
Родитель
00751b6a4f
Коммит
8bbc783f57
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче