"There was an error displaying this diff" when diffing a file that contains a "#" in the filename.

44 views
Skip to first unread message

Rob Petti

unread,
Aug 22, 2019, 3:34:16 PM8/22/19
to Review Board Community
Hi Folks,

We're having an issue with one of our SVN repositories right now. It appears almost as if ReviewBoard can't handle files that contain "#" in their names. I've attached a screenshot of the error. Of particular note is that the error seems to suggest that it's truncating the filename from '#' and erroneously trying to use that to locate the file in the repository.

Would anyone know how to overcome this problem? Obviously we could work around it by changing the file names, but this is a naming convention that's required by our product and cannot be changed.

Thanks!
~Rob
rb-hash-error.PNG

Rob Petti

unread,
Aug 27, 2019, 3:28:19 PM8/27/19
to Review Board Community
Hey Folks,

I've managed to narrow it down some more. It appears to be a problem in scmtools/svn/pysvn.py.

    def _do_on_path(self, cb, path, revision=HEAD):
        if not path:
            raise FileNotFoundError(path, revision)

        try:
            # path == "src/cws/QMS/Entities/NonconformanceBase#cws-nativeentity#.cws"

            # SVN expects to have URLs escaped. Take care to only
            # escape the path part of the URL.
            if self.client.is_url(normpath):
                pathtuple = urlsplit(normpath)
                path = pathtuple[2]
                if isinstance(path, six.text_type):
                    path = path.encode('utf-8', 'ignore')
                normpath = urlunsplit((pathtuple[0],
                                       pathtuple[1],
                                       quote(path),
                                       '', ''))

            normrev = self._normalize_revision(revision)
            return cb(normpath, normrev)


As you can see, it combines the path naively into a URL without escaping any characters, then tries to parse it as a URL to URL-escape the path portion of it, which obviously won't work.

I was able to fix my problem by changing the code as below. It didn't make any sense to me that it would parse it as a URL before escaping it, so I removed that whole section of the code and just encoded the file path before normalizing it.
    def _do_on_path(self, cb, path, revision=HEAD):
        if not path:
            raise FileNotFoundError(path, revision)

        try:
            normpath = self.normalize_path(quote(path.encode('utf-8', 'ignore')))

            normrev = self._normalize_revision(revision)
            return cb(normpath, normrev)


If this makes sense, should I open a review with my proposed changes?
Reply all
Reply to author
Forward
0 new messages