Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: recent-builds-2.0
-
Fix Version/s: recent-builds-2.0
-
Component/s: view-engine
-
Security Level: Public
-
Labels:None
Description
Document editing is using the following url http://lh:9000/couchBase/default/_all_docs?skip=0&include_docs=true&limit=5&_=1341509643238
it normally works except Steve has broken it on my box by uploading this:
# wget -O- -q 'http://lh:9000/couchBase/default/00000001'
{"_id":"00000001","_rev":"2-00027be31890c78a0000000000000000","name":"steve \"yen\"","job":1,"$expiration":0,"$flags":0}
And those quotes break all docs output massively:
wget -O- -q 'http://lh:9000/couchBase/default/_all_docs?skip=0&include_docs=true&limit=5&_=1341509643238'
{"total_rows":998000,"rows":[
{"id":"00000001","key":"00000001","value":{"rev":"2-00027be31890c78a0000000000000000"},"doc":{"_id":"00000001","_rev":"2-00027be31890c78a0000000000000000","name":"steve "yen"","job":1,"$expiration":0,"$flags":0}},
{"id":"00000002","key":"00000002","value":{"rev":"1-00027b84bccda3f10000000000000000"},"doc":{"_id":"00000002","_rev":"1-00027b84bccda3f10000000000000000","$expiration":0,"$flags":0}},
{"id":"00000004","key":"00000004","value":{"rev":"1-00027b84bcc993a90000000000000000"},"doc":{"_id":"00000004","_rev":"1-00027b84bcc993a90000000000000000","$expiration":0,"$flags":0}},
{"id":"00000006","key":"00000006","value":{"rev":"1-00027b84bcc9f7420000000000000000"},"doc":{"_id":"00000006","_rev":"1-00027b84bcc9f7420000000000000000","$expiration":0,"$flags":0}},
{"id":"00000007","key":"00000007","value":{"rev":"1-00027b84bccc52730000000000000000"},"doc":{"_id":"00000007","_rev":"1-00027b84bccc52730000000000000000","$expiration":0,"$flags":0}}
]
}
As you can see quotes inside steve "yen" are not escaped properly
it normally works except Steve has broken it on my box by uploading this:
# wget -O- -q 'http://lh:9000/couchBase/default/00000001'
{"_id":"00000001","_rev":"2-00027be31890c78a0000000000000000","name":"steve \"yen\"","job":1,"$expiration":0,"$flags":0}
And those quotes break all docs output massively:
wget -O- -q 'http://lh:9000/couchBase/default/_all_docs?skip=0&include_docs=true&limit=5&_=1341509643238'
{"total_rows":998000,"rows":[
{"id":"00000001","key":"00000001","value":{"rev":"2-00027be31890c78a0000000000000000"},"doc":{"_id":"00000001","_rev":"2-00027be31890c78a0000000000000000","name":"steve "yen"","job":1,"$expiration":0,"$flags":0}},
{"id":"00000002","key":"00000002","value":{"rev":"1-00027b84bccda3f10000000000000000"},"doc":{"_id":"00000002","_rev":"1-00027b84bccda3f10000000000000000","$expiration":0,"$flags":0}},
{"id":"00000004","key":"00000004","value":{"rev":"1-00027b84bcc993a90000000000000000"},"doc":{"_id":"00000004","_rev":"1-00027b84bcc993a90000000000000000","$expiration":0,"$flags":0}},
{"id":"00000006","key":"00000006","value":{"rev":"1-00027b84bcc9f7420000000000000000"},"doc":{"_id":"00000006","_rev":"1-00027b84bcc9f7420000000000000000","$expiration":0,"$flags":0}},
{"id":"00000007","key":"00000007","value":{"rev":"1-00027b84bccc52730000000000000000"},"doc":{"_id":"00000007","_rev":"1-00027b84bccc52730000000000000000","$expiration":0,"$flags":0}}
]
}
As you can see quotes inside steve "yen" are not escaped properly
It turns out that YAJL's stream parser unescapes strings before passing them to the callback.
The only solution (inefficient) is call YAJL's helpers to explicitly escape the string again.
Just sent a patch upstream to make it not unescape the string, and avoiding re-escaping it:
https://github.com/lloyd/yajl/pull/81
Will close this soon.