Skip to content

Commit

Permalink
fix: remove response factory auto escape xml character behavior.
Browse files Browse the repository at this point in the history
Hot fix: this commit removes the auto-escape xml character behavior that
might cause valid ssml tags to be escaped as well. Keeping the util function
for developer to opt-in to use.
  • Loading branch information
Zhang committed Mar 8, 2019
1 parent 5923afa commit 31ce953
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
5 changes: 2 additions & 3 deletions ask-sdk-core/lib/response/ResponseFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
Response,
ui,
} from 'ask-sdk-model';
import { escapeXmlCharacters } from '../util/SsmlUtils';
import { ResponseBuilder } from './ResponseBuilder';
import Stream = interfaces.audioplayer.Stream;
import AudioItem = interfaces.audioplayer.AudioItem;
Expand Down Expand Up @@ -80,7 +79,7 @@ export class ResponseFactory {
response.outputSpeech = {
type : 'SSML',
ssml : '<speak>'
+ escapeXmlCharacters(trimOutputSpeech(speechOutput))
+ trimOutputSpeech(speechOutput)
+ '</speak>',
playBehavior,
};
Expand All @@ -96,7 +95,7 @@ export class ResponseFactory {
outputSpeech : {
type : 'SSML',
ssml : '<speak>'
+ escapeXmlCharacters(trimOutputSpeech(repromptSpeechOutput))
+ trimOutputSpeech(repromptSpeechOutput)
+ '</speak>',
playBehavior,
},
Expand Down
20 changes: 0 additions & 20 deletions ask-sdk-core/tst/response/ResponseFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,6 @@ describe('ResponseFactory', () => {
expect(responseBuilder.reprompt(speechOutput, 'ENQUEUE').getResponse()).to.deep.equal(expectResponse);
});

it('should auto-escape invalid ssml character', () => {
const responseBuilder : ResponseBuilder = ResponseFactory.init();
const speechOutput = 'Hello World & Happy New Year!';
const expectResponse = {
outputSpeech: {
ssml: '<speak>' + `Hello World &amp; Happy New Year!` + '</speak>',
type: 'SSML',
},
reprompt : {
outputSpeech : {
ssml: '<speak>' + `Hello World &amp; Happy New Year!` + '</speak>',
type: 'SSML',
},
},
shouldEndSession : false,
};

expect(responseBuilder.speak(speechOutput).reprompt(speechOutput).getResponse()).to.deep.equal(expectResponse);
});

it('should build response with simple card', () => {
const responseBuilder : ResponseBuilder = ResponseFactory.init();
const cardTitle = 'Card Title';
Expand Down

0 comments on commit 31ce953

Please sign in to comment.