Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Push replicator now encodes non-string filter params as JSON.

I'm not sure whether such parameters are allowed, but JSON encoding seems like the reasonable
way to send them to the remote _changes feed (as opposed to calling ObjC -description on them,
which the code used to do...)
Potential fix for issue #239.
  • Loading branch information...
commit 78a2ad736b5dfe3a7b791a0099835e9b4ec0cd26 1 parent 5eda8af
@snej snej authored
Showing with 14 additions and 3 deletions.
  1. +14 −3 Source/ChangeTracker/TDChangeTracker.m
View
17 Source/ChangeTracker/TDChangeTracker.m
@@ -90,9 +90,20 @@ - (NSString*) changesFeedPath {
if (_filterName) {
[path appendFormat: @"&filter=%@", TDEscapeURLParam(_filterName)];
for (NSString* key in _filterParameters) {
- id value = _filterParameters[key];
- [path appendFormat: @"&%@=%@", TDEscapeURLParam(key),
- TDEscapeURLParam([value description])];
+ NSString* value = _filterParameters[key];
+ if (![value isKindOfClass: [NSString class]]) {
+ // It's ambiguous whether non-string filter params are allowed.
+ // If we get one, encode it as JSON:
+ NSError* error;
+ value = [TDJSON stringWithJSONObject: value options: TDJSONWritingAllowFragments
+ error: &error];
+ if (!value) {
+ Warn(@"Illegal filter parameter %@ = %@", key, _filterParameters[key]);
+ continue;
+ }
+ }
+ [path appendFormat: @"&%@=%@", TDEscapeURLParam(key),
+ TDEscapeURLParam(value)];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.