bugGNUstep - Bugs: bug #35701, Add API to get NSURL path without...

Group
 
 

bug #35701: Add API to get NSURL path without decoding %-escapes

Submitter:  Jens Alfke <snej>
Submitted:  Fri 02 Mar 2012 11:57:10 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  In Test
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 08 Mar 2012 04:16:50 AM UTC, comment #2: 

Jens, I just wanted to mention that GNUstep has a "work in progress" implementation of CoreFoundation.  I did quite some work on CFURL last month and would appreciate help test the results.  The library is called "corebase" and is under libs/corebase in the SVN repo. The CFURL implementation does include a CFURLCopyPath() implementation, and as far as know it is compatible with Apple's.  CFURLRef is not yet toll-free bridged to NSURL.

Stef <stefanbidi>
Group Member
Wed 07 Mar 2012 08:41:17 AM UTC, comment #1: 

Thanks.  I applied this patch but with a small change ... you missed implementing the new method in Source/Additions/NSURL+GNUstepBase.m

But ... I have zero experience using core foundation (and don't generally do any osx coding), so my attempt to implement the missing method is almost certainly wrong ... please could you check/correct as necessary.

Richard Frith-Macdonald <CaS>
Group Member
Fri 02 Mar 2012 11:57:10 PM UTC, original submission:  

GNUstep doesn't have a method equivalent to CFURLCopyPath, which returns the path portion of a URL without decoding %-escapes. This is important if you need to be able to work with paths that contain quoted slashes, i.e. "%2F" escapes -- the regular NSURL.path method decodes all the escapes so you can no longer tell %2F apart from /.

My app needs this functionality. (In the REST API I'm working with, path components may contain slashes if they are escaped as %2F.) In the original Mac/iOS code I use CFURLCopyPath, but I couldn't find a good way to do this in GNUstep. I don't want to bring in the entire CoreBase framework just for that one function.

Looking at NSURL.m, all I need to to is prevent one call to unescape(). I added a boolean parameter indicating whether to leave the escapes. So the existing -path method passes NO, and I created a new -pathWithEscapes method that passes YES.

Attached is a patch that implements this.

Jens Alfke <snej>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #25249:  pathWithEscapes.patch added by snej (2KiB - application/octet-stream - Patch implementing -[NSURL pathWithEscapes])

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by stefanbidi (Posted a comment)
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by snej (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-03-07 CaS StatusNone Fixed
        Open/ClosedOpen In Test
    2012-03-02 snej Attached File- Added pathWithEscapes.patch, #25249

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code