Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a0431b51
Commit
a0431b51
authored
Apr 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
0df90142
f38e3f2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+4
-1
changelogs/unreleased/markdown-autocomplete-escaping.yml
changelogs/unreleased/markdown-autocomplete-escaping.yml
+5
-0
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+15
-6
No files found.
app/assets/javascripts/gfm_auto_complete.js
View file @
a0431b51
...
...
@@ -468,7 +468,10 @@ class GfmAutoComplete {
// We can ignore this for quick actions because they are processed
// before Markdown.
if
(
!
this
.
setting
.
skipMarkdownCharacterTest
)
{
withoutAt
=
withoutAt
.
replace
(
/
([
~
\-
_*`
])
/g
,
'
\\
$&
'
);
withoutAt
=
withoutAt
.
replace
(
/
(
~~|`|
\*)
/g
,
'
\\
$1
'
)
.
replace
(
/
(\b)(
_+
)
/g
,
'
$1
\\
$2
'
)
// only escape underscores at the start
.
replace
(
/
(
_+
)(\b)
/g
,
'
\\
$1$2
'
);
// or end of words
}
return
`
${
at
}${
withoutAt
}
`
;
...
...
changelogs/unreleased/markdown-autocomplete-escaping.yml
0 → 100644
View file @
a0431b51
---
title
:
Only escape Markdown emphasis characters in autocomplete when necessary
merge_request
:
27457
author
:
type
:
changed
spec/frontend/gfm_auto_complete_spec.js
View file @
a0431b51
...
...
@@ -94,7 +94,7 @@ describe('GfmAutoComplete', () => {
});
it
(
'
should quote if value contains any non-alphanumeric characters
'
,
()
=>
{
expect
(
beforeInsert
(
atwhoInstance
,
'
~label-20
'
)).
toBe
(
'
~"label
\\
-20"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~label-20
'
)).
toBe
(
'
~"label-20"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~label 20
'
)).
toBe
(
'
~"label 20"
'
);
});
...
...
@@ -102,12 +102,21 @@ describe('GfmAutoComplete', () => {
expect
(
beforeInsert
(
atwhoInstance
,
'
~1234
'
)).
toBe
(
'
~"1234"
'
);
});
it
(
'
should escape Markdown emphasis characters, except in the first character
'
,
()
=>
{
expect
(
beforeInsert
(
atwhoInstance
,
'
@_group
'
)).
toEqual
(
'
@
\\
_group
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~_bug
'
)).
toEqual
(
'
~
\\
_bug
'
);
it
(
'
escapes Markdown strikethroughs when needed
'
,
()
=>
{
expect
(
beforeInsert
(
atwhoInstance
,
'
~a~bug
'
)).
toEqual
(
'
~"a~bug"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a~~bug~~
'
)).
toEqual
(
'
~"a
\\
~~bug
\\
~~"
'
);
});
it
(
'
escapes Markdown emphasis when needed
'
,
()
=>
{
expect
(
beforeInsert
(
atwhoInstance
,
'
~a_bug_
'
)).
toEqual
(
'
~a_bug
\\
_
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a _bug_
'
)).
toEqual
(
'
~"a
\\
_bug
\\
_"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a*bug*
'
)).
toEqual
(
'
~"a
\\
*bug
\\
*"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a *bug*
'
)).
toEqual
(
'
~"a
\\
*bug
\\
*"
'
);
});
it
(
'
escapes Markdown code spans when needed
'
,
()
=>
{
expect
(
beforeInsert
(
atwhoInstance
,
'
~a`bug`
'
)).
toEqual
(
'
~"a
\\
`bug
\\
`"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a `bug`
'
)).
toEqual
(
'
~"a
\\
`bug
\\
`"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a ~bug
'
)).
toEqual
(
'
~"a
\\
~bug"
'
);
expect
(
beforeInsert
(
atwhoInstance
,
'
~a **bug
'
)).
toEqual
(
'
~"a
\\
*
\\
*bug"
'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment