don't buffer string escaping for php response writer either: SOLR-377

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@585775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2007-10-18 01:40:57 +00:00
parent 883aab2010
commit 87e233db19
1 changed files with 6 additions and 7 deletions

View File

@ -77,25 +77,24 @@ class PHPWriter extends JSONWriter {
@Override
protected void writeKey(String fname, boolean needsEscaping) throws IOException {
writeStr(null, fname, needsEscaping);
writer.write("=>");
writer.write('=');
writer.write('>');
}
@Override
public void writeStr(String name, String val, boolean needsEscaping) throws IOException {
if (needsEscaping) {
StringBuilder sb = new StringBuilder(val.length());
sb.append('\'');
writer.write('\'');
for (int i=0; i<val.length(); i++) {
char ch = val.charAt(i);
switch (ch) {
case '\'':
case '\\': sb.append('\\'); sb.append(ch); break;
case '\\': writer.write('\\'); writer.write(ch); break;
default:
sb.append(ch);
writer.write(ch);
}
}
sb.append('\'');
writer.append(sb);
writer.write('\'');
} else {
writer.write('\'');
writer.write(val);