Help with URL loading

Discussion in 'Mac Programming' started by wbynum, Jun 29, 2012.

  1. wbynum macrumors newbie

    Jun 29, 2012
    At my work we have an Objective C app that loads a URL into a stripped down web browser. From what I understand the browser was written using the webkit framework. This works well until the URL has URL encoded characters (example: %22). When the URL is loaded the URL encoded parameters are corrupted. Below is what I am seeing.

    Code Snippet:

    Debugging in Xcode shows "RequestURL" to contain the following correct URL parameters:

    When the URL is actually loaded, I have a JS popup that displays window.location.href:

    It's like it is interpreting the URL encoded characters before the request is actually made. If I take out the URL encoded characters, then things work fine. Also, if I just hit the URL directly in Safari, things work fine. Any ideas? Thanks.
  2. chown33 macrumors 604

    Aug 9, 2009
    You'll probably need to post the code that uses Webkit.

    When I look at the two strings:
    A: %22testing%22&signalRConnectionId=123
    B: -2.642388e-229sting2signalRConnectionId=123
    String B looks somewhat like string A has been used as a format string, but the parameters being expanded don't really exist. I've hilited the "format" parts of string A, and the "expanded" parts of string B:
    A: [COLOR="Red"]%22te[/COLOR]sting[COLOR="Red"]%22&[/COLOR]signalRConnectionId=123
    B: [COLOR="Blue"]-2.642388e-229[/COLOR]sting[COLOR="Blue"]2[/COLOR]signalRConnectionId=123
    I'm not saying the formats are working. I'm just saying it looks like the code might be using a stringWithFormat:, or an sprintf(), or some other "withFormat" function or method when it shouldn't be.

    Another possibility is defective Javascript for the popup. Again, you'd have to post code, or post an actual URL representing the fail-case.
  3. wbynum thread starter macrumors newbie

    Jun 29, 2012
    Thanks for the tips. I was kind of thinking the same thing. Seems like it is using the % as a format flag (like %d in C). I'll try to dive down into the Webkit code. I know nothing about Objective C though. One of those deals at work where something just get's put on your plate. Thanks again.
  4. chown33 macrumors 604

    Aug 9, 2009
    It's not exactly printf-like, nor is it exactly stringWithFormat-like. Neither one has a %t specifier, so it's kinda weird that "%22te" appears to be producing a floating-point number in %e format. But it seems like a good guess it's doing some kind of formatting, since I can't think of a simpler way to get a floating-point number inserted like that.

Share This Page