|
|
@@ -50,9 +50,12 @@ class FattureInCloudClient
|
|
50
|
50
|
'page' => max(1, $page),
|
|
51
|
51
|
'per_page' => 20,
|
|
52
|
52
|
];
|
|
53
|
|
- $term = trim(str_replace("'", '', $term));
|
|
|
53
|
+ $term = $this->searchTerm($term);
|
|
54
|
54
|
if ($term !== '') {
|
|
55
|
|
- $params['q'] = "(name like '%{$term}%' or vat_number like '%{$term}%' or tax_code like '%{$term}%')";
|
|
|
55
|
+ // contains, senza % e senza parentesi: like '%…%' viene bloccato
|
|
|
56
|
+ // dal gateway di Fatture in Cloud con un 403 senza corpo JSON.
|
|
|
57
|
+ $quoted = "'{$term}'";
|
|
|
58
|
+ $params['q'] = "name contains {$quoted} or vat_number contains {$quoted} or tax_code contains {$quoted}";
|
|
56
|
59
|
}
|
|
57
|
60
|
|
|
58
|
61
|
$json = $this->decode($this->http()->get($this->url('/entities/clients'), $params));
|
|
|
@@ -76,6 +79,13 @@ class FattureInCloudClient
|
|
76
|
79
|
];
|
|
77
|
80
|
}
|
|
78
|
81
|
|
|
|
82
|
+ private function searchTerm(string $term): string
|
|
|
83
|
+ {
|
|
|
84
|
+ $term = trim(str_replace(["'", '\\', '%', '(', ')', "\0", "\n", "\r"], '', $term));
|
|
|
85
|
+
|
|
|
86
|
+ return mb_substr($term, 0, 80);
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
79
|
89
|
public function getClient(int $id): array
|
|
80
|
90
|
{
|
|
81
|
91
|
$json = $this->decode($this->http()->get($this->url('/entities/clients/'.$id), [
|