@diviops/mcp-server 1.5.8 → 1.5.9

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.
Files changed (2) hide show
  1. package/dist/wp-client.js +30 -2
  2. package/package.json +1 -1
package/dist/wp-client.js CHANGED
@@ -73,6 +73,32 @@ const BLOCK_CONTENT_KEYS = new Set([
73
73
  'header_content', // create_tb_template
74
74
  'footer_content', // create_tb_template
75
75
  ]);
76
+ /**
77
+ * Endpoints whose target storage is a PHP-serialized WP option (or other
78
+ * non-JSON serialization) rather than block-markup `post_content`. For these,
79
+ * quote-escape normalization is harmful: the under-escape pass inserts literal
80
+ * `\` characters into bare-`"`-containing `$variable(...)$` token strings,
81
+ * which are then PHP-serialized verbatim into the option — producing the
82
+ * pathological `\"` (literal backslash + quote) byte sequence inside the
83
+ * stored value where canonical VB output stores a bare `"` (the surrounding
84
+ * PHP array provides all the structure; the string itself is uninterpreted).
85
+ *
86
+ * The frontend-render side tolerates the malformed bytes via a regex-based
87
+ * extractor, but the VB-UI field-display layer strict-parses the inner
88
+ * payload and silently falls back to placeholder values when it can't decode
89
+ * — see #716.
90
+ *
91
+ * Match by endpoint prefix so any future `/preset/*` route inherits the
92
+ * exclusion automatically. Block-markup writers (`/section/*`, `/module/*`,
93
+ * `/page/*`, `/canvas/*`, `/tb-layout/*`, `/tb-template/*`, `/library/save`,
94
+ * `/render-preview`, `/validate-blocks`) still receive normalization.
95
+ */
96
+ const NON_BLOCK_STORAGE_PREFIXES = [
97
+ '/preset/',
98
+ ];
99
+ function endpointSkipsNormalization(endpoint) {
100
+ return NON_BLOCK_STORAGE_PREFIXES.some((prefix) => endpoint.startsWith(prefix));
101
+ }
76
102
  function normalizeBody(value, withinBlockTree = false) {
77
103
  if (typeof value === 'string') {
78
104
  return withinBlockTree ? normalizeQuoteEscapes(value) : value;
@@ -121,7 +147,8 @@ export class WPClient {
121
147
  },
122
148
  };
123
149
  if (body && method !== 'GET') {
124
- fetchOptions.body = JSON.stringify(normalizeBody(body));
150
+ const normalized = endpointSkipsNormalization(endpoint) ? body : normalizeBody(body);
151
+ fetchOptions.body = JSON.stringify(normalized);
125
152
  }
126
153
  const response = await fetch(url, fetchOptions);
127
154
  if (!response.ok) {
@@ -183,7 +210,8 @@ export class WPClient {
183
210
  },
184
211
  };
185
212
  if (body && method !== 'GET') {
186
- fetchOptions.body = JSON.stringify(normalizeBody(body));
213
+ const normalized = endpointSkipsNormalization(endpoint) ? body : normalizeBody(body);
214
+ fetchOptions.body = JSON.stringify(normalized);
187
215
  }
188
216
  const response = await fetch(url, fetchOptions);
189
217
  const rawBody = await response.text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diviops/mcp-server",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "MCP server exposing Divi 5 Visual Builder as tools for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",