You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Create an intra-page link in an Image tag in the wiki markup like this:
[[Image:skull.jpg|link=sandbox:createNewPage#Section Three]]
The basic problem is that the "#" character is getting URL encoded, and
should not.
What is the expected output?
sandbox:createNewPage#Section_Three
What do you see instead?
sandbox:createNewPage%23Section_Three
What version of the product are you using? On what operating system?
3.0.13
Please provide any additional information below.
To fix this problem, I overrode AbstractWikiModel.encodeTitleToUrl() like this:
private static final String SPLIT_INTRA_PAGE_URL_RE = "^([^#]+)#?(.*)$";
public static final Pattern SPLIT_INTRA_PAGE_URL_PATTERN =
Pattern.compile( SPLIT_INTRA_PAGE_URL_RE );
@Override
public String encodeTitleToUrl(String wikiTitle, boolean
firstCharacterAsUpperCase) {
String encodedUrl;
Matcher m = SPLIT_INTRA_PAGE_URL_PATTERN.matcher( wikiTitle );
if ( m.matches() ) {
// wikiTitle, which is a partial URL, contains an intra-page link (like
this: docs:page-name#intr-page-link)
String lhs = m.group( 1 );
String rhs = m.group( 2 );
if ( StringUtils.isEmpty( rhs ) ) {
encodedUrl = Encoder.encodeTitleToUrl(lhs, firstCharacterAsUpperCase );
} else {
encodedUrl = Encoder.encodeTitleToUrl(lhs, firstCharacterAsUpperCase )
+ "#" + Encoder.encodeTitleToUrl(rhs, firstCharacterAsUpperCase );
}
} else {
encodedUrl = Encoder.encodeTitleToUrl(wikiTitle,
firstCharacterAsUpperCase );
}
return encodedUrl;
}
Original issue reported on code.google.com by steven.b...@gmail.com on 2 Dec 2009 at 5:01
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
steven.b...@gmail.com
on 2 Dec 2009 at 5:01The text was updated successfully, but these errors were encountered: