Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
2ab1d915
Commit
2ab1d915
authored
Aug 14, 2017
by
lain
Browse files
Use unicode regex in mentions and links.
parent
7d34cec5
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/formatter.ex
View file @
2ab1d915
defmodule
Pleroma
.
Formatter
do
defmodule
Pleroma
.
Formatter
do
alias
Pleroma
.
User
alias
Pleroma
.
User
@link_regex
~r/https?:\/
\
/
[\
w
\
.
\
/
?=
\
-
#%&]+[\w]/
@link_regex
~r/https?:\/
\
/
[\
w
\
.
\
/
?=
\
-
#%&]+[\w]/
u
def
linkify
(
text
)
do
def
linkify
(
text
)
do
Regex
.
replace
(
@link_regex
,
text
,
"<a href='
\\
0'>
\\
0</a>"
)
Regex
.
replace
(
@link_regex
,
text
,
"<a href='
\\
0'>
\\
0</a>"
)
end
end
...
@@ -14,7 +14,7 @@ def parse_tags(text) do
...
@@ -14,7 +14,7 @@ def parse_tags(text) do
def
parse_mentions
(
text
)
do
def
parse_mentions
(
text
)
do
# Modified from https://www.w3.org/TR/html5/forms.html#valid-e-mail-address
# Modified from https://www.w3.org/TR/html5/forms.html#valid-e-mail-address
regex
=
~r/@[a-zA-Z0-9.!#$%&'*+\/
=
?^
_
`
{
|
}
~
-
]
+
@
?[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?(?:
\
.
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?)
*/
regex
=
~r/@[a-zA-Z0-9.!#$%&'*+\/
=
?^
_
`
{
|
}
~
-
]
+
@
?[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?(?:
\
.
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?)
*/
u
Regex
.
scan
(
regex
,
text
)
Regex
.
scan
(
regex
,
text
)
|>
List
.
flatten
|>
List
.
flatten
...
...
Write
Preview
Supports
Markdown
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