InternalLinkType accepts links that does not start with /content


Using ResourceLink ends up in NPE when the content reference does not starts with /content

Although this can be prevented using validation in edit dialog, it is still strange that InternalLinkType accepts such links:

InternalLinkType must only accept links that start with /content


Stefan Seifert
June 12, 2017, 1:16 PM

the accepts(String) method is only used for "guessing" the link type when no link type information is present - if it is present it should be possible to link to anywhere, not necessarily only to /content. at least this is the current assumption.

i still cannot reproduce your problem - if i pass in an invalid link references like "crap" in the unit test the link is marked as invalid - but no NPE is thrown.

Masoud Rozati
June 12, 2017, 1:00 PM

well, the accepts(String) method has such a limitation and it would be consistent if the accepts(LinkRequst) method also implements the same behaviour.

You can reproduce the error with a linkContentRef without the leading slash, e.g. linkContentRef="scrap"

Stefan Seifert
June 12, 2017, 12:49 PM

there is no hard-coded limitation that only links with /content area allowed, although it would be quite unusual to have links other than to /content/*.

i tried to create a unittest to reproduce the problem, but was not able to come up with one that throws this NPE - it seems the path is null, but this should not be the case.

i create the unittest in this branch:

Cannot Reproduce


Masoud Rozati


Masoud Rozati




Affects versions