]> granicus.if.org Git - clang/commitdiff
[analyzer] scan-view: don't ever serve absolute paths.
authorJordan Rose <jordan_rose@apple.com>
Mon, 29 Apr 2013 17:23:06 +0000 (17:23 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 29 Apr 2013 17:23:06 +0000 (17:23 +0000)
At one point in time scan-view allowed absolute paths to reference files
within the server root, but this doesn't seem to be used anymore, and
caused problems if a server-root-relative path actually matched an
absolute path to an existing file. This patch just treats paths as
server-root-relative all the time.

PR15843

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180715 91177308-0d34-0410-b5e6-96231b3b80d8

tools/scan-view/ScanView.py

index 32570b985838497cc887d4e113b44a38c461cdd9..ee08baa8bad058e5c196bb66ead3d71b121c3d48 100644 (file)
@@ -686,16 +686,8 @@ File Bug</h3>
         if components[-1] == '':
             components[-1] = 'index.html'
 
-        suffix = '/'.join(components)
-
-        # The summary may reference source files on disk using rooted
-        # paths. Make sure these resolve correctly for now.
-        # FIXME: This isn't a very good idea... we should probably
-        # mark rooted paths somehow.        
-        if os.path.exists(posixpath.join('/', suffix)):
-            path = posixpath.join('/', suffix)
-        else:
-            path = posixpath.join(self.server.root, suffix)
+        relpath = '/'.join(components)
+        path = posixpath.join(self.server.root, relpath)
 
         if self.server.options.debug > 1:
             print >>sys.stderr, '%s: SERVER: sending path "%s"'%(sys.argv[0],
@@ -708,8 +700,8 @@ File Bug</h3>
 
     def send_path(self, path):
         # If the requested path is outside the root directory, do not open it
-        rel = os.path.abspath(os.path.join(self.server.root, path))
-        if not rel.startswith(os.path.abspath(self.server.root) ):
+        rel = os.path.abspath(path)
+        if not rel.startswith(os.path.abspath(self.server.root)):
           return self.send_404()
         
         ctype = self.guess_type(path)