Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
c062d058
Commit
c062d058
authored
6 years ago
by
Karishma Chadha
Browse files
Options
Downloads
Patches
Plain Diff
Escape special characters in user defined strings that can appear in the toolbox xml.
parent
52a6136c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/make-toolbox-xml.js
+16
-0
16 additions, 0 deletions
src/lib/make-toolbox-xml.js
test/integration/blocks.test.js
+18
-0
18 additions, 0 deletions
test/integration/blocks.test.js
with
34 additions
and
0 deletions
src/lib/make-toolbox-xml.js
+
16
−
0
View file @
c062d058
...
@@ -138,6 +138,18 @@ const motion = function (isStage, targetId) {
...
@@ -138,6 +138,18 @@ const motion = function (isStage, targetId) {
`
;
`
;
};
};
const
xmlEscape
=
function
(
unsafe
)
{
return
unsafe
.
replace
(
/
[
<>&'"
]
/g
,
c
=>
{
switch
(
c
)
{
case
'
<
'
:
return
'
<
'
;
case
'
>
'
:
return
'
>
'
;
case
'
&
'
:
return
'
&
'
;
case
'
\'
'
:
return
'
'
'
;
case
'
"
'
:
return
'
"
'
;
}
});
};
const
looks
=
function
(
isStage
,
targetId
,
costumeName
,
backdropName
)
{
const
looks
=
function
(
isStage
,
targetId
,
costumeName
,
backdropName
)
{
const
hello
=
ScratchBlocks
.
ScratchMsgs
.
translate
(
'
LOOKS_HELLO
'
,
'
Hello!
'
);
const
hello
=
ScratchBlocks
.
ScratchMsgs
.
translate
(
'
LOOKS_HELLO
'
,
'
Hello!
'
);
const
hmm
=
ScratchBlocks
.
ScratchMsgs
.
translate
(
'
LOOKS_HMM
'
,
'
Hmm...
'
);
const
hmm
=
ScratchBlocks
.
ScratchMsgs
.
translate
(
'
LOOKS_HMM
'
,
'
Hmm...
'
);
...
@@ -714,6 +726,10 @@ const makeToolboxXML = function (isStage, targetId, categoriesXML,
...
@@ -714,6 +726,10 @@ const makeToolboxXML = function (isStage, targetId, categoriesXML,
costumeName
=
''
,
backdropName
=
''
,
soundName
=
''
)
{
costumeName
=
''
,
backdropName
=
''
,
soundName
=
''
)
{
const
gap
=
[
categorySeparator
];
const
gap
=
[
categorySeparator
];
costumeName
=
xmlEscape
(
costumeName
);
backdropName
=
xmlEscape
(
backdropName
);
soundName
=
xmlEscape
(
soundName
);
const
everything
=
[
const
everything
=
[
xmlOpen
,
xmlOpen
,
motion
(
isStage
,
targetId
),
gap
,
motion
(
isStage
,
targetId
),
gap
,
...
...
This diff is collapsed.
Click to expand it.
test/integration/blocks.test.js
+
18
−
0
View file @
c062d058
...
@@ -191,6 +191,24 @@ describe('Working with the blocks', () => {
...
@@ -191,6 +191,24 @@ describe('Working with the blocks', () => {
await
clickText
(
'
newname
'
,
scope
.
blocksTab
);
await
clickText
(
'
newname
'
,
scope
.
blocksTab
);
});
});
test
(
'
Renaming costume with a special character should not break toolbox
'
,
async
()
=>
{
await
loadUri
(
uri
);
await
clickXpath
(
'
//button[@title="Try It"]
'
);
// Rename the costume
await
clickText
(
'
Costumes
'
);
const
el
=
await
findByXpath
(
"
//input[@value='costume1']
"
);
await
el
.
sendKeys
(
'
<NewCostume>
'
);
// Make sure it is updated in the block menu
await
clickText
(
'
Code
'
);
await
clickText
(
'
Looks
'
,
scope
.
blocksTab
);
await
driver
.
sleep
(
500
);
// Wait for scroll to finish
await
clickText
(
'
<NewCostume>
'
,
scope
.
blocksTab
);
await
clickText
(
'
Sound
'
,
scope
.
blocksTab
);
});
// NOTE: This test describes the current behavior so that changes are not
// NOTE: This test describes the current behavior so that changes are not
// introduced inadvertly, but I know this is not the desired behavior
// introduced inadvertly, but I know this is not the desired behavior
test
(
'
Adding costumes DOES NOT update the default costume name in the toolbox
'
,
async
()
=>
{
test
(
'
Adding costumes DOES NOT update the default costume name in the toolbox
'
,
async
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment