Cms: UrlHelper::siteUrl should only ever output…site URLs.

Created on 14 Oct 2020  Â·  3Comments  Â·  Source: craftcms/cms

If you pass UrlHelper::siteUrl an absolute url, eg, UrlHelper::siteUrl('https://a-malicious-link-here.com'), it will return that URL, which is not a site url.

That seems misleading, I don't think it should (I think that logic should _only_ be in UrlHelper::url).

enhancement

Most helpful comment

An InvalidArgumentException would make more sense than those, I think.

All 3 comments

I don’t think replacing the host name to the site’s host name would be expected either, if that’s what you’re suggesting. The only other behavior I would consider here is to throw an exception in the event the passed-in “path” turns out to be an absolute/root-relative/protocol-relative URL.

Maybe it could return null, false or an empty string?

An InvalidArgumentException would make more sense than those, I think.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitboxfw picture bitboxfw  Â·  3Comments

benface picture benface  Â·  3Comments

davist11 picture davist11  Â·  3Comments

RitterKnightCreative picture RitterKnightCreative  Â·  3Comments

michel-o picture michel-o  Â·  3Comments