Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Fix for Github issue #272 #274

Merged
merged 1 commit into from
Nov 5, 2015
Merged

Fix for Github issue #272 #274

merged 1 commit into from
Nov 5, 2015

Conversation

DennisHeimbigner
Copy link
Contributor

The problem was that java.net.URI and java.net.URL
could not parse url strings that were based on
backslash escape rather than %xx escape.
The General Rule is this:

  1. any url given to e.g. HTTPSession or HTTPMethod
    or HTTPFactory is assumed to be the url
    that is wanted on the server side.
  2. THREDDS - Simple joinExisting failing in 4.2.9 #1 means that, again as a general rule, urlstrings
    given to those classes should not be %xx escaped
    unless that is what you want on the server side.
  3. The key to understand is that
    a. those classes will internally %xx encode the url string they are
    given even if the url string already is %xx encoded.
    b. on the server side, the %xx encoding will be performed
    on the incoming url string. This means that the %xx encoded
    string you originally sent is the one given to the servlet.
    Bottom line: do not do %xx encoding yourself unless your server side
    code is expected to see a %xx encoded url.

Anyway, the fix is to create a procedure -- HTTPUtil.parseToURI() --
that can properly create a java.net.URI object from a backslash
escaped url string. Any time you need to create a URI object,
you should do so using that procedure.

Misc. Notes:
-- Test program TestURIParse is also included.
-- In several places, I changed the use of URL to URI
so this new code could be used. The primary effect was
to replace MalFormedURLException with URISyntaxException
in many places.
-- minor unrelated fix to TestFormBuilder is also included in this pull request:
changed port numbers for the tests.

The problem was that java.net.URI and java.net.URL
could not parse url strings that were based on
backslash escape rather than %xx escape.
The General Rule is this:
1. any url given to e.g. HTTPSession or HTTPMethod
   or HTTPFactory is assumed to be the url
   that is wanted on the server side.
2. #1 means that, again as a general rule, urlstrings
   given to those classes should not be %xx escaped
   unless that is what you want on the server side.
3. The key to understand is that
   a. those classes will internally %xx encode the url string they are
      given even if the url string already is %xx encoded.
   b. on the server side, the %xx encoding will be performed
      on the incoming url string. This means that the %xx encoded
      string you originally sent is the one given to the servlet.
Bottom line: do not do %xx encoding yourself unless your server side
code is expected to see a %xx encoded url.

Anyway, the fix is to create a procedure -- HTTPUtil.parseToURI() --
that can properly create a java.net.URI object from a backslash
escaped url string. Any time you need to create a URI object,
you should do so using that procedure.
cwardgar added a commit that referenced this pull request Nov 5, 2015
@cwardgar cwardgar merged commit 0bd9318 into master Nov 5, 2015
@DennisHeimbigner DennisHeimbigner deleted the issue_272_master branch November 6, 2015 02:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants