Skip to content

Instantly share code, notes, and snippets.

@cotto
Created January 16, 2012 22:35
Show Gist options
  • Save cotto/1623402 to your computer and use it in GitHub Desktop.
Save cotto/1623402 to your computer and use it in GitHub Desktop.
allow escaped commans in services requests
diff --git a/sites/all/modules/services/services.module b/sites/all/modules/services/services.module
index 7f49837..97ba65a 100644
--- a/sites/all/modules/services/services.module
+++ b/sites/all/modules/services/services.module
@@ -476,9 +476,11 @@ function services_resource_build_index_query($schema, $order, $page, $fields, $s
if (is_array($service_params)) {
foreach ($service_params as $param_field => $param_value) {
$in_placeholders = array();
- foreach (explode(',', $param_value) as $single_value) {
+ // Split on unescaped commas.
+ foreach (preg_split('#(?<!\\\),#', $param_value) as $single_value) {
+ watchdog('services', "found param '$single_value'");
$in_placeholders[] = db_type_placeholder($schema['fields'][$param_field]['type']);
- $query_params[] = $single_value;
+ $query_params[] = str_replace('\\,', ',', $single_value);
}
$where[] = $primary_table . '.' . $param_field . ' IN (' . implode(',', $in_placeholders) . ')';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment