Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [1.2.0-beta.3](https://github.com/mi-examples/pp-dev/compare/v1.2.0-beta.2...v1.2.0-beta.3) (2026-08-07)


### Bug Fixes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the heading-level jump.

Line 1 uses an H1 release heading. Line 4 uses an H3 heading. This skips H2 and triggers markdownlint MD001. Change ### Bug Fixes to ## Bug Fixes.

Suggested fix
-### Bug Fixes
+## Bug Fixes
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Bug Fixes
## Bug Fixes
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 4-4: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 4, Change the “Bug Fixes” heading from H3 to H2 so it
follows the H1 release heading without skipping a level and satisfies
markdownlint MD001.

Source: Linters/SAST tools


* Variables Editor client script fails to parse, blanking the whole UI ([2e48b2e](https://github.com/mi-examples/pp-dev/commit/2e48b2e69c12124a6d300503a80b40f649de1316))

# [1.2.0-beta.2](https://github.com/mi-examples/pp-dev/compare/v1.2.0-beta.1...v1.2.0-beta.2) (2026-08-07)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@metricinsights/pp-dev",
"type": "module",
"version": "1.2.0-beta.2",
"version": "1.2.0-beta.3",
"description": "Portal Page dev build tool",
"bin": {
"pp-dev": "bin/pp-dev.js"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/variables-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ function escapeHtml(s) {
// (see DistService.saveTemplateVariablesFile). Backslash/quote-escape for the JS-string
// context first, then HTML-escape the result so it can't break out of the attribute either.
function escapeJsAttr(s) {
return escapeHtml(String(s).replace(/\\/g, '\\\\').replace(/'/g, "\\'"));
return escapeHtml(String(s).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, "\\\\'"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Escape JavaScript line terminators as well.

Although the backslash fix resolves the reported issue, escapeJsAttr() still leaves \r, \n, U+2028, and U+2029 unchanged. A schema-derived list-column name containing one of these characters can make the generated single-quoted inline handler invalid. Add JavaScript escapes for these characters before calling escapeHtml().

Suggested source-level fix
-  return escapeHtml(String(s).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, "\\\\'"));
+  return escapeHtml(
+    String(s)
+      .replace(/\\\\/g, '\\\\\\\\')
+      .replace(/'/g, "\\\\'")
+      .replace(/\\r/g, '\\\\r')
+      .replace(/\\n/g, '\\\\n')
+      .replace(/\\u2028/g, '\\\\u2028')
+      .replace(/\\u2029/g, '\\\\u2029'),
+  );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/variables-editor.ts` at line 529, Update escapeJsAttr() to escape
carriage return, newline, U+2028, and U+2029 in addition to backslashes and
single quotes, applying these JavaScript escapes before escapeHtml() so
generated single-quoted inline handlers remain valid.

}

function showBanner(type, html) {
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/lib/variables-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,26 @@ describe('registerVariablesEditorRoutes', () => {
expect(res.body).not.toContain('id="tab-schema"');
expect(res.body).not.toContain('id="save-btn"');
});

// Every `<script>` block is built via string concatenation inside one giant template
// literal — a backslash-escaping mistake there (e.g. a regex like /\\/) is invisible to
// `tsc`/eslint (it's just characters inside a string) and only breaks at runtime when the
// browser parses it, which none of the tests above would ever catch. `new Function` parses
// without executing, so this fails fast on any embedded-script SyntaxError.
it('embeds syntactically valid client-side JavaScript in every <script> block', async () => {
const app = register({ miAPI: { isTemplateLess: false } as unknown as MiAPI });
const res = makeRes();

app.handlers.get(`GET ${VARIABLES_EDITOR_PATH}`)!({}, res);

const html = res.body as string;
const scripts = [...html.matchAll(/<script>([\s\S]*?)<\/script>/g)].map((m) => m[1]);

expect(scripts.length).toBeGreaterThan(0);

for (const script of scripts) {
expect(() => new Function(script)).not.toThrow();
}
});
});
});