Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XWiki
xwiki-rendering
Commits
94168509
Unverified
Commit
94168509
authored
Jan 13, 2022
by
Thomas Mortagne
Committed by
GitHub
Jan 13, 2022
Browse files
Merge pull request #196 from michitux/XRENDERING-612
parents
c28ff532
48cdf245
Changes
4
Hide whitespace changes
Inline
Side-by-side
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/parser/xhtml/wikimodel/XHTMLXWikiGeneratorListener.java
View file @
94168509
...
@@ -66,6 +66,11 @@ public class XHTMLXWikiGeneratorListener extends DefaultXWikiGeneratorListener
...
@@ -66,6 +66,11 @@ public class XHTMLXWikiGeneratorListener extends DefaultXWikiGeneratorListener
*/
*/
private
static
final
Pattern
URL_SCHEME_PATTERN
=
Pattern
.
compile
(
"[a-zA-Z0-9+.-]*://"
);
private
static
final
Pattern
URL_SCHEME_PATTERN
=
Pattern
.
compile
(
"[a-zA-Z0-9+.-]*://"
);
/**
* Prefix for mailto-links.
*/
private
static
final
String
MAILTO_PREFIX
=
"mailto:"
;
private
static
final
String
CLASS_ATTRIBUTE
=
"class"
;
private
static
final
String
CLASS_ATTRIBUTE
=
"class"
;
/**
/**
...
@@ -142,7 +147,9 @@ public void onImage(WikiReference reference)
...
@@ -142,7 +147,9 @@ public void onImage(WikiReference reference)
* <ul>
* <ul>
* <li>UC1: the reference points to a valid URL, we return a reference of type "url",
* <li>UC1: the reference points to a valid URL, we return a reference of type "url",
* e.g. {@code http://server/path/reference#anchor}</li>
* e.g. {@code http://server/path/reference#anchor}</li>
* <li>UC2: the reference is not a valid URL, we return a reference of type "path",
* <li>UC2: the reference is a mailto: link, we return a reference of type "mailto",
* e.g., {@code mailto:user@example.com}</li>
* <li>UC3: the reference is not a valid URL, we return a reference of type "path",
* e.g. {@code path/reference#anchor}</li>
* e.g. {@code path/reference#anchor}</li>
* </ul>
* </ul>
*
*
...
@@ -158,8 +165,11 @@ private ResourceReference computeResourceReference(String rawReference)
...
@@ -158,8 +165,11 @@ private ResourceReference computeResourceReference(String rawReference)
if
(
matcher
.
lookingAt
())
{
if
(
matcher
.
lookingAt
())
{
// We have UC1
// We have UC1
reference
=
new
ResourceReference
(
rawReference
,
ResourceType
.
URL
);
reference
=
new
ResourceReference
(
rawReference
,
ResourceType
.
URL
);
}
else
{
}
else
if
(
rawReference
.
startsWith
(
MAILTO_PREFIX
))
{
// We have UC2
// We have UC2
reference
=
new
ResourceReference
(
rawReference
.
substring
(
MAILTO_PREFIX
.
length
()),
ResourceType
.
MAILTO
);
}
else
{
// We have UC3
reference
=
new
ResourceReference
(
rawReference
,
ResourceType
.
PATH
);
reference
=
new
ResourceReference
(
rawReference
,
ResourceType
.
PATH
);
}
}
...
...
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/test/resources/xhtml10/simple/link/link5.in.txt
→
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/test/resources/xhtml10/simple/link/link5.in.
1.
txt
View file @
94168509
File moved
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/test/resources/xhtml10/simple/link/link5.out.txt
→
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/test/resources/xhtml10/simple/link/link5.
in
out.txt
View file @
94168509
File moved
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/test/resources/xhtml10/specific/link/link6.test
0 → 100644
View file @
94168509
.
#-----------------------------------------------------
.
input
|
xhtml
/
1.0
.
#-----------------------------------------------------
<
p
>
one
<
a
href
=
"mailto:john@doe.com"
>
two
</
a
>
three
</
p
>
.
#-----------------------------------------------------
.
expect
|
event
/
1.0
.
#-----------------------------------------------------
beginDocument
beginParagraph
onWord
[
one
]
onSpace
beginLink
[
Typed
=
[
true
]
Type
=
[
mailto
]
Reference
=
[
john
@
doe
.
com
]]
[
false
]
onWord
[
two
]
endLink
[
Typed
=
[
true
]
Type
=
[
mailto
]
Reference
=
[
john
@
doe
.
com
]]
[
false
]
onSpace
onWord
[
three
]
endParagraph
endDocument
\ No newline at end of file
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