Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-551

External links do not allow any other protocol than http

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.3.6, 1.4
    • 1.1.2
    • None
    • None
    • any
    • Yes

      If you enter any external link with a protocol different from http, the string "http://" is prepended to it.

      This is due to STKUtil only checking of a string prefix of "http://", but fails to detect other protocols such as https. I've attached a new implementation of both affected STKUtil methods. I couldn't create an actual patch in the given timeframe easily, sorry.

      The following two methods accept any protocol, but still prepend "http://" in case none is given:

      public static String getExternalLink(Content content, String linkNodeName){
      String externalLink = content.getNodeData(linkNodeName).getString();

      if(!externalLink.contains("://"))

      { externalLink = "http://"+externalLink; }

      return externalLink;
      }

      public static String getExternalLinkTitle(Content content, String linkNodeName, String linkTitleNodeName){
      String linkTitle = content.getNodeData(linkTitleNodeName).getString();
      if(StringUtils.isNotEmpty(linkTitle))

      { return linkTitle; }

      String externalLink = content.getNodeData(linkNodeName).getString();
      int idx = externalLink.indexOf("://");
      if(idx != -1){
      if (externalLink.length() > idx+3)

      { externalLink = externalLink.substring(idx+3); }

      else

      { externalLink = ""; }

      }
      return externalLink;
      }

        Acceptance criteria

              ochytil Ondrej Chytil
              awedermp Andreas Weder (MP) (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: