Changeset 1462

Show
Ignore:
Timestamp:
07/07/08 07:41:10 (2 months ago)
Author:
rob
Message:

Fixed vfs uri handling to properly decode fragments in windows path urls
* makeTabActive now attempts to match on normalized URLs
* added testcase for windows urls with fragments

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/frame.py

    r1457 r1462  
    690690        @return: True if URL was found, False if not. 
    691691        """ 
    692         mode = self.tabs.moveSelectionToURL(url) 
     692        normalized = vfs.normalize(url) 
     693        self.dprint("url=%s normalized=%s" % (url, normalized)) 
     694        mode = self.tabs.moveSelectionToURL(normalized) 
    693695        if mode: 
    694             url = vfs.normalize(url) 
    695             mode.showInitialPosition(url) 
     696            mode.showInitialPosition(normalized) 
    696697        return mode is not None 
    697698     
  • trunk/peppy/fundamental.py

    r1458 r1462  
    593593 
    594594    def showInitialPosition(self, url): 
     595        self.dprint("url=%s scheme=%s auth=%s path=%s query=%s fragment=%s" % (url, url.scheme, url.authority, url.path, url.query, url.fragment)) 
    595596        if url.fragment: 
    596597            line = int(url.fragment) 
  • trunk/peppy/vfs/itools/uri/generic.py

    r1026 r1462  
    738738        scheme, authority, path, query, fragment = urlsplit(data) 
    739739         
    740         # Some special cases for Windows paths 
     740        # Some special cases for Windows paths c:/a/b#4 and file:///c:/a/b#4. 
     741        # urlsplit has problems with the scheme, leading slashes in the path, 
     742        # and doesn't split out the fragment properly 
    741743        if len(scheme) == 1: 
    742744            # found a windows drive name instead of path, because urlsplit 
    743745            # thinks the scheme is "c" for Windows paths like "c:/a/b" 
     746            if "#" in path: 
     747                # the fragment is improperly placed in the path 
     748                path, fragment = path.rsplit("#", 1) 
    744749            path = "%s:%s" % (scheme, path) 
    745750            scheme = "file" 
     
    748753            # like "file:///c:/a/b" -- it thinks the path is "/c:/a/b", which 
    749754            # to be correct requires removing the leading slash. 
    750             path = "%s:%s" % (path[1].lower(), path[3:]) 
     755            drive = path[1].lower() 
     756            path = path[3:] 
     757            if "#" in path: 
     758                path, fragment = path.rsplit("#", 1) 
     759            path = "%s:%s" % (drive, path) 
    751760         
    752761        # The path 
  • trunk/tests/test_vfs.py

    r929 r1462  
    187187        self.assertEqual('c:/stuff/blah', uri.path) 
    188188        self.assertEqual('file', uri.scheme) 
     189        uri = vfs.get_reference('c:/stuff/blah#5') 
     190        self.assertEqual('c:/stuff/blah', str(uri.path)) 
     191        self.assertEqual('5', uri.fragment) 
     192        self.assertEqual('file', uri.scheme) 
    189193         
    190194    def test_windows_normalize(self):