Skip to content

Commit f276e07

Browse files
authored
Escaping fix broke a number of things (#14145) (#14154)
* Fixes for escaping * Push a comment ot start PR again * Cache task is failing * Remove cache task * Not fixing so just put back cache task
1 parent 5065d31 commit f276e07

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/client/datascience/jupyter/jupyterDebugger.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
'use strict';
44
import type { nbformat } from '@jupyterlab/coreutils';
55
import { inject, injectable, named } from 'inversify';
6+
// tslint:disable-next-line: no-require-imports
7+
import unescape = require('lodash/unescape');
68
import * as path from 'path';
79
import * as uuid from 'uuid/v4';
810
import { DebugConfiguration, Disposable } from 'vscode';
@@ -473,8 +475,10 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
473475
if (outputs.length > 0) {
474476
const data = outputs[0].data;
475477
if (data && data.hasOwnProperty('text/plain')) {
478+
// Plain text should be escaped by our execution engine. Unescape it so
479+
// we can parse it.
476480
// tslint:disable-next-line:no-any
477-
return (data as any)['text/plain'];
481+
return unescape((data as any)['text/plain']);
478482
}
479483
if (outputs[0].output_type === 'stream') {
480484
const stream = outputs[0] as nbformat.IStream;

src/datascience-ui/interactive-common/cellOutput.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ export class CellOutput extends React.Component<ICellOutputProps> {
314314
input = JSON.stringify(output.data);
315315
renderWithScrollbars = true;
316316
isText = true;
317-
} else if (output.output_type === 'execute_result' && input && input.hasOwnProperty('text/plain')) {
317+
} else if (
318+
output.output_type === 'execute_result' &&
319+
input &&
320+
input.hasOwnProperty('text/plain') &&
321+
!input.hasOwnProperty('text/html')
322+
) {
318323
// Plain text should actually be shown as html so that escaped HTML shows up correctly
319324
mimeType = 'text/html';
320325
isText = true;

src/test/datascience/notebook.functional.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ suite('DataScience notebook tests', () => {
182182
const error = cell.outputs[0].evalue;
183183
if (error) {
184184
assert.ok(error, 'Error not found when expected');
185-
assert.equal(error, errorString, 'Unexpected error found');
185+
assert.ok(error.toString().includes(errorString), 'Unexpected error found');
186186
}
187187
}
188188

@@ -757,7 +757,7 @@ suite('DataScience notebook tests', () => {
757757
await server!.waitForIdle(10000);
758758

759759
console.log('Verifying restart');
760-
await verifyError(server, 'a', `name 'a' is not defined`);
760+
await verifyError(server, 'a', `is not defined`);
761761
} catch (exc) {
762762
assert.ok(
763763
exc instanceof JupyterKernelPromiseFailedError,
@@ -1031,7 +1031,7 @@ a`,
10311031
mimeType: 'text/plain',
10321032
cellType: 'code',
10331033
result: `<a href=f>`,
1034-
verifyValue: (d) => assert.equal(d, escape(`<a href=f>`), 'XML not escaped')
1034+
verifyValue: (d) => assert.ok(d.includes(escape(`<a href=f>`)), 'XML not escaped')
10351035
},
10361036
{
10371037
markdownRegEx: undefined,

0 commit comments

Comments
 (0)