#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Need Help - I am not even a beginner in Java :(


    Hi ,

    Firstly I am at stage 0 in java. Well I have never been into any programming, but it seems like I need a little help to solve a task. I have been given a code and asked to incorporate it to fix an error.

    here's the code -

    4a5
    > import java.net.*;
    225c226,227
    < String file = fileElem.getAttribute("URI");
    ---
    > String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");
    > log.info(file);
    486c488
    < String file = fileElem.getAttribute("URI");
    ---
    > String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");


    It is a simple URL encoding issue which could be fixed by incorporating this code. But I am too dumb that I don't even know how to do it!
    Well there is a program used to decode files, But it has got simple URL encoding issue, which could be fixed by code given above.

    Please have a look at the below links so you will get a clear very clear Idea.

    https://tag3u lp55xczs3 pn.oni on.to/
    https://ta g3ulp55x czs3pn.oni on.to/req uiem-3.3.5-w in.zip
    https://tag 3ulp55 xczs 3pn.on ion.to/requ iem-3.3.5-s rc.zip - source code

    https://tag 3ulp55xcz s3pn.oni on.t o/cg...a448&offset=40


    {Please remove spaces from the links given above}
    The above links are to a program used to decode files. its a freeware, and the source code is too available. the particular version that works for me is 3.3.5 but unfortunately it has a URL encoding issue. The developer of that program gave me the fix to the issue and has asked me to incorporate it and fix it for myself. But I as I said I have never been into any programming, and I really don't understand anything here. But I would really appreciate it if some one will teach me how to do it step-by-step and how to fix it!

    Thanks in advance.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    What the author gave you is a simple diff patch. You can either pass that through a program called patch, which will change the appropriate lines, or you can do it yourself. Here's what to do:
    Code:
    4a5
    > import java.net.*;
    The line 4a5 means go to line 4 and then add the following code:
    Code:
     
    import java.net.*;
    Next we have:
    Code:
    225c226,227
    < String file = fileElem.getAttribute("URI");
    ---
    > String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");
    > log.info(file)
    From the 225c226,227, we can tell that the change is around line 225 of the file and the letter c means to change that line to something else. (As you may have guessed, the < indicates what should be removed and the > indicates what it should be replaced with) What you're looking for is a line that looks like this:
    Code:
    String file = fileElem.getAttribute("URI");
    Replace that line with the following two lines:
    Code:
    String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");
    log.info(file)
    Next, we have the following diff:
    Code:
    486c488
    < String file = fileElem.getAttribute("URI");
    ---
    > String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");
    As you can guess, this means go to line 486 and look in that area for
    Code:
    String file = fileElem.getAttribute("URI");
    and replace it with:
    Code:
    String file = URLDecoder.decode(fileElem.getAttribute("URI"), "UTF-8");
    Then save and recompile the source code and there you have it.
    Last edited by Scorpions4ever; December 13th, 2012 at 05:06 AM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo