Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image links that have intra-page link are broken. #31

Closed
GoogleCodeExporter opened this issue Apr 15, 2015 · 2 comments
Closed

Image links that have intra-page link are broken. #31

GoogleCodeExporter opened this issue Apr 15, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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

@GoogleCodeExporter
Copy link
Author

Original comment by axelclk@gmail.com on 4 Dec 2009 at 4:35

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Fixed with: http://code.google.com/p/gwtwiki/source/detail?r=532

Original comment by axelclk@gmail.com on 4 Dec 2009 at 5:18

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant