next-tinacms-cloudinary 27.0.2 → 27.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/handlers.js CHANGED
@@ -81,6 +81,11 @@ function resolveDirectory(rawDirectory) {
81
81
  return normalized + "/";
82
82
  }
83
83
 
84
+ // src/search-expression.ts
85
+ function escapeSearchValue(value) {
86
+ return value.replace(/[\\"*]/g, "\\$&");
87
+ }
88
+
84
89
  // src/upload-filename.ts
85
90
  function safeUploadName(originalName) {
86
91
  const base = originalName.split(/[/\\]/).pop() || "";
@@ -157,8 +162,10 @@ async function uploadMedia(req, res) {
157
162
  }
158
163
  async function listMedia(req, res, opts) {
159
164
  try {
165
+ const rawDirectory = req.query.directory;
166
+ const directory = Array.isArray(rawDirectory) ? rawDirectory[0] : rawDirectory;
160
167
  const mediaListOptions = {
161
- directory: req.query.directory || '""',
168
+ directory: directory || '""',
162
169
  limit: parseInt(req.query.limit, 10) || 500,
163
170
  offset: req.query.offset,
164
171
  filesOnly: req.query.filesOnly === "true" || false
@@ -175,14 +182,14 @@ async function listMedia(req, res, opts) {
175
182
  throw e;
176
183
  }
177
184
  }
178
- const query = useRootDirectory ? 'folder=""' : `folder="${mediaListOptions.directory}"`;
185
+ const query = useRootDirectory ? 'folder=""' : `folder="${escapeSearchValue(mediaListOptions.directory)}"`;
179
186
  const response = await cloudinary.search.expression(query).max_results(mediaListOptions.limit).next_cursor(mediaListOptions.offset).execute();
180
187
  const files = response.resources.map(getCloudinaryToTinaFunc(opts));
181
- cloudinary.api.folders = (directory = '""') => {
188
+ cloudinary.api.folders = (directory2 = '""') => {
182
189
  if (useRootDirectory) {
183
190
  return cloudinary.api.root_folders();
184
191
  } else {
185
- return cloudinary.api.sub_folders(directory);
192
+ return cloudinary.api.sub_folders(directory2);
186
193
  }
187
194
  };
188
195
  let folders = [];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Escape a value for interpolation into a quoted Cloudinary Search API term.
3
+ *
4
+ * Cloudinary treats a double-quoted term literally except for `"` and `*`,
5
+ * which keep their meaning and must be backslash-escaped. Backslash is escaped
6
+ * too as a conservative hedge; callers reach this through resolveDirectory,
7
+ * which already rejects backslashes, so that branch is unreachable today.
8
+ *
9
+ * See https://cloudinary.com/documentation/search_expressions
10
+ */
11
+ export declare function escapeSearchValue(value: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next-tinacms-cloudinary",
3
3
  "type": "module",
4
- "version": "27.0.2",
4
+ "version": "27.0.3",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "files": [
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "cloudinary": "^1.41.3",
23
- "multer": "1.4.5-lts.1"
23
+ "multer": "2.2.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/crypto-js": "^3.1.47",
@@ -30,11 +30,11 @@
30
30
  "react": "^18.3.1",
31
31
  "react-dom": "^18.3.1",
32
32
  "typescript": "^5.7.3",
33
- "@tinacms/scripts": "1.6.2",
34
- "tinacms": "3.11.0"
33
+ "@tinacms/scripts": "1.6.3",
34
+ "tinacms": "3.12.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "tinacms": "^3.11.0"
37
+ "tinacms": "^3.12.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "registry": "https://registry.npmjs.org"