Various fixes for URL canonicalization.
authorJelmer Vernooij <jelmer@jelmer.uk>
Wed, 23 May 2018 02:06:58 +0000 (03:06 +0100)
committerJelmer Vernooij <jelmer@jelmer.uk>
Wed, 23 May 2018 02:06:58 +0000 (03:06 +0100)
subvertpy/_ra.c
subvertpy/tests/test_subr.py
subvertpy/tests/test_wc.py
subvertpy/util.c

index f89e5d0e223cf5f42248a5dc42ce22308e0cab6d..4f5125d4f3fca569e390910e913f4c15defac0be 100644 (file)
@@ -1059,12 +1059,12 @@ static PyObject *ra_do_switch(PyObject *self, PyObject *args)
                return NULL;
        }
 
-    switch_url = py_object_to_svn_uri(py_switch_url, temp_pool);
-    if (switch_url == NULL) {
-        apr_pool_destroy(temp_pool);
-        ra->busy = false;
-        return NULL;
-    }
+       switch_url = py_object_to_svn_uri(py_switch_url, temp_pool);
+       if (switch_url == NULL) {
+               apr_pool_destroy(temp_pool);
+               ra->busy = false;
+               return NULL;
+       }
 
        result_pool = Pool(NULL);
        if (result_pool == NULL) {
index a7c517ddea304ebfff795224d7abd15edfefb29d..b80290f04541f70aa50310b21655446524c83f59 100644 (file)
@@ -24,7 +24,7 @@ class UriCanonicalizeTests(TestCase):
 
     def test_canonicalize(self):
         self.assertEqual(
-                'https://www.example.com/',
+                'https://www.example.com',
                 uri_canonicalize('https://www.example.com/'))
         self.assertEqual(
                 'https://www.example.com(bla)',
index b236dea089ecb47debb344f1c76b69698fe6ec52..56036712ca6484ff645083ee1152e2535b680b35 100644 (file)
@@ -288,7 +288,7 @@ class AdmObjTests(SubversionTestCase):
         self.assertEqual("bar", bar.name)
         self.assertEqual(NODE_FILE, bar.kind)
         self.assertEqual(wc.SCHEDULE_NORMAL, bar.schedule)
-        self.assertIs(None, bar.checksum)
+        self.assertEqual('52419dba51d65210e87bf52dc1072145', bar.checksum)
         self.assertEqual(1, bar.cmt_rev)
         self.assertEqual(1, bar.revision)
 
index 2700c65e03c54b49d40e41119a12f0d434a11845..7536f613abc29765afaddf97df022b13a4c54abc 100644 (file)
@@ -47,7 +47,7 @@ const char *
 svn_uri_canonicalize(const char *uri,
                      apr_pool_t *result_pool)
 {
-       return svn_path_uri_from_iri(uri, result_pool);
+       return svn_path_canonicalize(uri, result_pool);
 }
 
 const char *
@@ -180,26 +180,26 @@ char *py_object_to_svn_string(PyObject *obj, apr_pool_t *pool)
 
 const char *py_object_to_svn_uri(PyObject *obj, apr_pool_t *pool)
 {
-    const char *ret;
-    PyObject *bytes_obj = NULL;
+       const char *ret;
+       PyObject *bytes_obj = NULL;
 
-    if (PyUnicode_Check(obj)) {
-        bytes_obj = obj = PyUnicode_AsUTF8String(obj);
-        if (obj == NULL) {
-            return NULL;
-        }
-    }
+       if (PyUnicode_Check(obj)) {
+               bytes_obj = obj = PyUnicode_AsUTF8String(obj);
+               if (obj == NULL) {
+                       return NULL;
+               }
+       }
 
-    if (PyBytes_Check(obj)) {
-        ret = svn_uri_canonicalize(PyBytes_AsString(obj), pool);
-        Py_XDECREF(bytes_obj);
-        return ret;
-    } else {
-        PyErr_SetString(PyExc_TypeError,
-                        "URIs need to be UTF-8 bytestrings or unicode strings");
-        Py_XDECREF(bytes_obj);
-        return NULL;
-    }
+       if (PyBytes_Check(obj)) {
+               ret = svn_uri_canonicalize(PyBytes_AsString(obj), pool);
+               Py_XDECREF(bytes_obj);
+               return ret;
+       } else {
+               PyErr_SetString(PyExc_TypeError,
+                                               "URIs need to be UTF-8 bytestrings or unicode strings");
+               Py_XDECREF(bytes_obj);
+               return NULL;
+       }
 }
 
 const char *py_object_to_svn_relpath(PyObject *obj, apr_pool_t *pool)
@@ -503,7 +503,7 @@ PyObject *prop_hash_to_dict(apr_hash_t *props)
                        py_key = Py_None;
                        Py_INCREF(py_key);
                } else {
-                       py_key = PyUnicode_FromString(key);
+                       py_key = PyBytes_FromStringAndSize(key, klen);
                }
                if (PyDict_SetItem(py_props, py_key, py_val) != 0) {
                        Py_DECREF(py_key);