Skip to content

Commit 0bf6cdd

Browse files
committed
allow to escape || character with \|| for tags
1 parent 2cf66c3 commit 0bf6cdd

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

controllers/TagsController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public function tags() {
186186
// Filter for specific tags with "?tag=foo || bar"
187187
$tagNames = !empty($this->queryParams['tag'])
188188
? explode(' || ', $this->queryParams['tag']): array();
189+
// Replace \|| with || to allow for tags with literal '||'.
190+
$tagNames = array_map(function ($name) {
191+
return str_replace("\||", "||", $name);
192+
}, $tagNames);
189193
Zotero_DB::beginTransaction();
190194
foreach ($tagNames as $tagName) {
191195
$tagIDs = Zotero_Tags::getIDs($this->objectLibraryID, $tagName);

model/API.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,11 @@ public static function getSearchParamValues($params, $param) {
13321332
// Separate into boolean OR parts
13331333
$parts = preg_split("/\s+\|\|\s+/", $val);
13341334

1335+
// Replace \|| with || to allow for tags with literal '||'.
1336+
$parts = array_map(function ($part) {
1337+
return str_replace("\||", "||", $part);
1338+
}, $parts);
1339+
13351340
$val = array(
13361341
'negation' => $negation,
13371342
'values' => $parts

0 commit comments

Comments
 (0)