Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3584

Https helper functions return wrong values if server name equals application context name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.0
    • 7.0.7, 8.0.4.1
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Examples using Https.getCompleteContext(), but this issue applies to all methods in Https using indexOf to split the url
      -getCompleteContext
      -getCompleteServerName
      -possible other methods?

      Setup a ZK application where context = server name.
      Easiest: App context: localhost, server = localhost
      Use Https helper functions to get values from the current request such as:
      String completeContext = Https.getCompleteContext(((HttpServletRequest)Executions.getCurrent().getNativeRequest()));

      Actual Result

      With context name = server name
      getCompleteContext returns:
      https://localhost

      Expected Result

      With context name != server name
      getCompleteContext returns:
      https://localhost:8443/localhostdifferent

      Debug Info

      Root Cause

      sb.indexOf(ctx) will always return the first position of the context string. If the context string appear more than once (server name and context name) then the returned value will be incorect, as the string is cut too early

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h