#57749typolink(): Incorrect generation for cross-protocol link when port is set in Host Header
Description
Situation:
- TYPO3 runs behind a proxy, that proxy sets an explicit :80 for HTTP and :443 for HTTPS traffic in the Host-Header. The Host-Header thus looks like this: Host: mydomain.com:80
- Links to HTTPS-only pages are present on HTTP-Pages
Expected result:
Links to the HTTPS-Pages are generated correcty, i.e. https://mydomain.com/secure/page
Actual result:
Links to the HTTPS-Pages incorrectly contain the HTTP port and thus do not work, i.e. https://mydomain.com:80/secure/page
Reason:
The logic when generating a link (typolink-function) goes like this:
- Check targetDomain of link. If targetDomain is identical to current domain (this is the case), set targetDomain to “”
- Check whether an HTTPS-link is desired.
- If HTTPS is desired AND targetDomain is blank (which now is the case), set the targetDomain to the contents of the Host-Header (which, in this case, includes :80)
- Prepend targetDomain to generated link
And thus, the link gets an incorrect port. In my opinion, in step1, targetDomain should only be set to “” if target domain AND protocol are the same as current domain and protocol, as “” seems to indicate no change.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.