@nataliapc/mcp-openmsx 1.1.3 → 1.1.4
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/openmsx.js +2 -2
- package/dist/server.js +2 -2
- package/dist/utils.js +28 -2
- package/package.json +1 -1
package/dist/openmsx.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @license GPL2
|
|
6
6
|
*/
|
|
7
7
|
import fs from "fs/promises";
|
|
8
|
-
import { extractDescriptionFromXML, decodeHtmlEntities } from "./utils.js";
|
|
8
|
+
import { extractDescriptionFromXML, decodeHtmlEntities, encodeHtmlEntities } from "./utils.js";
|
|
9
9
|
import { spawn } from 'child_process';
|
|
10
10
|
import path from 'path';
|
|
11
11
|
/**
|
|
@@ -265,7 +265,7 @@ export class OpenMSX {
|
|
|
265
265
|
async sendCommand(command) {
|
|
266
266
|
try {
|
|
267
267
|
// Send command
|
|
268
|
-
this.writeData(`<command>${command}</command>\n`);
|
|
268
|
+
this.writeData(`<command>${encodeHtmlEntities(command)}</command>\n`);
|
|
269
269
|
// Read response using readData()
|
|
270
270
|
const output = (await this.readData()).trim();
|
|
271
271
|
// Look for reply tags in the output
|
package/dist/server.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* through TCL commands via stdio.
|
|
7
7
|
*
|
|
8
8
|
* @package @nataliapc/mcp-openmsx
|
|
9
|
-
* @version 1.1.
|
|
9
|
+
* @version 1.1.4
|
|
10
10
|
* @author Natalia Pujol Cremades (@nataliapc)
|
|
11
11
|
* @license GPL2
|
|
12
12
|
*/
|
|
@@ -21,7 +21,7 @@ import fs from "fs/promises";
|
|
|
21
21
|
import path from "path";
|
|
22
22
|
import { openMSXInstance } from "./openmsx.js";
|
|
23
23
|
// Version info for CLI
|
|
24
|
-
const PACKAGE_VERSION = "1.1.
|
|
24
|
+
const PACKAGE_VERSION = "1.1.4";
|
|
25
25
|
// Defaults for openMSX paths
|
|
26
26
|
var OPENMSX_EXECUTABLE = 'openmsx';
|
|
27
27
|
var OPENMSX_SHARE_DIR = '/usr/share/openmsx';
|
package/dist/utils.js
CHANGED
|
@@ -32,16 +32,16 @@ export function decodeHtmlEntities(text) {
|
|
|
32
32
|
'>': '>',
|
|
33
33
|
'&': '&',
|
|
34
34
|
'"': '"',
|
|
35
|
+
' ': ' ',
|
|
35
36
|
''': "'",
|
|
36
37
|
'/': '/',
|
|
37
38
|
'`': '`',
|
|
38
39
|
'=': '=',
|
|
40
|
+
''': "'",
|
|
39
41
|
''': "'",
|
|
40
42
|
'/': '/',
|
|
41
43
|
'`': '`',
|
|
42
44
|
'=': '=',
|
|
43
|
-
''': "'",
|
|
44
|
-
' ': ' ',
|
|
45
45
|
'
': '\n',
|
|
46
46
|
'
': '\n',
|
|
47
47
|
' ': '\n',
|
|
@@ -52,3 +52,29 @@ export function decodeHtmlEntities(text) {
|
|
|
52
52
|
return htmlEntities[entity] || entity;
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Encode a plain text to HTML entities, also escaping characters with ASCII >= 127
|
|
57
|
+
* @param text - String to encode
|
|
58
|
+
* @returns string - String with HTML entities encoded
|
|
59
|
+
*/
|
|
60
|
+
export function encodeHtmlEntities(text) {
|
|
61
|
+
const htmlEntities = {
|
|
62
|
+
'<': '<',
|
|
63
|
+
'>': '>',
|
|
64
|
+
'&': '&',
|
|
65
|
+
'"': '"',
|
|
66
|
+
"'": ''',
|
|
67
|
+
'=': '=',
|
|
68
|
+
'/': '/',
|
|
69
|
+
};
|
|
70
|
+
return text.replace(/[\u00A0-\uFFFF<>&"'`=\/]/g, (char) => {
|
|
71
|
+
if (htmlEntities[char]) {
|
|
72
|
+
return htmlEntities[char];
|
|
73
|
+
}
|
|
74
|
+
const code = char.charCodeAt(0);
|
|
75
|
+
if (code >= 127) {
|
|
76
|
+
return `&#${code};`;
|
|
77
|
+
}
|
|
78
|
+
return char;
|
|
79
|
+
});
|
|
80
|
+
}
|