Skip to content

Commit bcb2ba1

Browse files
renovate[bot]zobo
andauthored
fix: parsing logic error and update dependency @xmldom/xmldom to ^0.9.8 (#1044)
* fix(deps): update dependency @xmldom/xmldom to ^0.9.8 * Update error api * Fixed a parsing logic error --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Damjan Cvetko <damjan.cvetko@gmail.com>
1 parent ce29078 commit bcb2ba1

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@vscode/debugadapter": "^1.68.0",
4747
"@vscode/debugprotocol": "^1.68.0",
48-
"@xmldom/xmldom": "^0.8.4",
48+
"@xmldom/xmldom": "^0.9.8",
4949
"buffer-crc32": "^1.0.0",
5050
"dotenv": "^17.2.1",
5151
"file-url": "^3.0.0",

src/dbgp.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,18 @@ export class DbgpConnection extends EventEmitter {
9292
// append the last piece of the response
9393
const lastResponsePiece = data.slice(0, this._dataLength - this._chunksDataLength)
9494
this._chunks.push(lastResponsePiece)
95-
this._chunksDataLength += data.length
95+
this._chunksDataLength += lastResponsePiece.length
9696
const response = Buffer.concat(this._chunks, this._chunksDataLength)
9797
// call response handler
9898
const xml = iconv.decode(response, ENCODING)
9999
const parser = new DOMParser({
100-
errorHandler: {
101-
warning: warning => {
102-
this.emit('warning', warning)
103-
},
104-
error: error => {
105-
this.emit('error', error instanceof Error ? error : new Error(error as string))
106-
},
107-
fatalError: error => {
108-
this.emit('error', error instanceof Error ? error : new Error(error as string))
109-
},
100+
onError: (level, msg) => {
101+
if (level === 'warning') {
102+
this.emit('warning', msg)
103+
}
104+
if (level === 'error' || level === 'fatalError') {
105+
this.emit('error', new Error(msg))
106+
}
110107
},
111108
})
112109
this.emit('log', `-> ${xml.replace(/[\0\n]/g, '')}`)

src/proxyConnect.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ export class ProxyConnect extends EventEmitter {
155155
/** Parse data from response server and emit the relevant notification. */
156156
private _responseStrategy(data: Buffer) {
157157
try {
158-
const documentElement = this._parser.parseFromString(
159-
decode(data, ENCODING),
160-
'application/xml'
161-
).documentElement
158+
const documentElement = this._parser.parseFromString(decode(data, ENCODING), 'application/xml')
159+
.documentElement!
162160
const isSuccessful = documentElement.getAttribute('success') === '1'
163161
const error = documentElement.firstChild
164162
if (isSuccessful && documentElement.nodeName === 'proxyinit') {

0 commit comments

Comments
 (0)