• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28529 (tree)
Time2019-03-13 06:17:00
Authorstefankueng

Log Message

use svn_uri_canonicalize_safe and svn_dirent_canonicalize_safe instead of the unsafe ones.

Change Summary

Incremental Difference

--- trunk/src/SVN/SVN.cpp (revision 28528)
+++ trunk/src/SVN/SVN.cpp (revision 28529)
@@ -1928,8 +1928,8 @@
19281928 {
19291929 // we don't have a BOM, so we have to try to figure out
19301930 // the encoding using heuristics. But only if the line is long enough
1931- int nullcount = 0;
1932- for (int i = 0; i < line->len; ++i)
1931+ size_t nullcount = 0;
1932+ for (size_t i = 0; i < line->len; ++i)
19331933 {
19341934 if (line->data[i] == 0)
19351935 ++nullcount;
--- trunk/src/SVN/SVNExternals.cpp (revision 28528)
+++ trunk/src/SVN/SVNExternals.cpp (revision 28529)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010-2015 - TortoiseSVN
3+// Copyright (C) 2010-2015, 2019 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -81,7 +81,10 @@
8181 if (svn_path_is_url(url))
8282 {
8383 /* "http://server/path" */
84- *resolved_url = svn_uri_canonicalize(url, result_pool);
84+ const char *canonicalized_url = nullptr;
85+ SVN_ERR(svn_uri_canonicalize_safe(&canonicalized_url, nullptr, url, result_pool, scratch_pool));
86+ *resolved_url = canonicalized_url;
87+
8588 return SVN_NO_ERROR;
8689 }
8790
@@ -187,9 +190,12 @@
187190
188191 parent_dir_uri.path = (char *)svn_path_compose(base_components,
189192 scratch_pool);
190- *resolved_url = svn_uri_canonicalize(apr_uri_unparse(scratch_pool,
191- &parent_dir_uri, 0),
192- result_pool);
193+ const char *canonicalized_url = nullptr;
194+ SVN_ERR(svn_uri_canonicalize_safe(&canonicalized_url, nullptr,
195+ apr_uri_unparse(scratch_pool, &parent_dir_uri, 0),
196+ result_pool, scratch_pool));
197+ *resolved_url = canonicalized_url;
198+
193199 return SVN_NO_ERROR;
194200 }
195201
@@ -207,9 +213,11 @@
207213 const char *scheme;
208214
209215 SVN_ERR(uri_scheme(&scheme, repos_root_url, scratch_pool));
210- *resolved_url = svn_uri_canonicalize(apr_pstrcat(scratch_pool, scheme,
211- ":", url, (char *)NULL),
212- result_pool);
216+ const char *canonicalized_url = nullptr;
217+ SVN_ERR(svn_uri_canonicalize_safe(&canonicalized_url, nullptr,
218+ apr_pstrcat(scratch_pool, scheme, ":", url, (char *)NULL),
219+ result_pool, scratch_pool));
220+ *resolved_url = canonicalized_url;
213221 return SVN_NO_ERROR;
214222 }
215223
@@ -218,9 +226,12 @@
218226 if (url[0] == '/')
219227 {
220228 parent_dir_uri.path = (char *)url;
221- *resolved_url = svn_uri_canonicalize(apr_uri_unparse(scratch_pool,
222- &parent_dir_uri, 0),
223- result_pool);
229+
230+ const char *canonicalized_url = nullptr;
231+ SVN_ERR(svn_uri_canonicalize_safe(&canonicalized_url, nullptr,
232+ apr_uri_unparse(scratch_pool, &parent_dir_uri, 0),
233+ result_pool, scratch_pool));
234+ *resolved_url = canonicalized_url;
224235 return SVN_NO_ERROR;
225236 }
226237
--- trunk/src/SVN/SVNPatch.cpp (revision 28528)
+++ trunk/src/SVN/SVNPatch.cpp (revision 28529)
@@ -1,6 +1,6 @@
1-// TortoiseMerge - a Diff/Patch program
1+// TortoiseMerge - a Diff/Patch program
22
3-// Copyright (C) 2010-2015, 2017 - TortoiseSVN
3+// Copyright (C) 2010-2015, 2017, 2019 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -312,33 +312,57 @@
312312 m_patchfile.Replace('\\', '/');
313313 m_targetpath.Replace('\\', '/');
314314
315- m_filetopatch = path.Mid(m_targetpath.GetLength()+1);
315+ m_filetopatch = path.Mid(m_targetpath.GetLength() + 1);
316316 m_filetopatch.Replace('\\', '/');
317317
318318 apr_pool_create_ex(&scratchpool, m_pool, abort_on_pool_failure, NULL);
319319 svn_error_clear(svn_client_create_context2(&ctx, SVNConfig::Instance().GetConfig(m_pool), scratchpool));
320320
321+ const char *patch_abspath = nullptr;
322+ err = svn_uri_canonicalize_safe(&patch_abspath, nullptr,
323+ CUnicodeUtils::GetUTF8(m_patchfile),
324+ scratchpool, scratchpool);
325+ if (err)
326+ {
327+ m_errorStr = GetErrorMessage(err);
328+ svn_error_clear(err);
329+ apr_pool_destroy(scratchpool);
330+ return false;
331+ }
332+
333+ const char *local_abspath = nullptr;
334+ err = svn_uri_canonicalize_safe(&local_abspath, nullptr,
335+ CUnicodeUtils::GetUTF8(m_targetpath),
336+ scratchpool, scratchpool);
337+ if (err)
338+ {
339+ m_errorStr = GetErrorMessage(err);
340+ svn_error_clear(err);
341+ apr_pool_destroy(scratchpool);
342+ return false;
343+ }
344+
321345 m_nRejected = 0;
322- err = svn_client_patch(svn_dirent_canonicalize(CUnicodeUtils::GetUTF8(m_patchfile), scratchpool), // patch_abspath
323- svn_dirent_canonicalize(CUnicodeUtils::GetUTF8(m_targetpath), scratchpool), // local_abspath
324- false, // dry_run
325- m_nStrip, // strip_count
326- false, // reverse
327- true, // ignore_whitespace
328- true, // remove_tempfiles
329- patchfile_func, // patch_func
330- this, // patch_baton
331- ctx, // client context
332- scratchpool);
346+ err = svn_client_patch(patch_abspath, // patch_abspath
347+ local_abspath, // local_abspath
348+ false, // dry_run
349+ m_nStrip, // strip_count
350+ false, // reverse
351+ true, // ignore_whitespace
352+ true, // remove_tempfiles
353+ patchfile_func, // patch_func
354+ this, // patch_baton
355+ ctx, // client context
356+ scratchpool);
333357
334- apr_pool_destroy(scratchpool);
335-
336358 if (err)
337359 {
338360 m_errorStr = GetErrorMessage(err);
339361 svn_error_clear(err);
362+ apr_pool_destroy(scratchpool);
340363 return false;
341364 }
365+ apr_pool_destroy(scratchpool);
342366
343367 return true;
344368 }
@@ -568,16 +592,24 @@
568592
569593 apr_array_header_t *targets = apr_array_make (scratchpool, 1, sizeof(const char *));
570594
571- (*((const char **) apr_array_push (targets))) = svn_dirent_canonicalize(CUnicodeUtils::GetUTF8(path), scratchpool);
595+ const char *canonicalized_path = nullptr;
596+ svn_error_clear(svn_uri_canonicalize_safe(&canonicalized_path, nullptr, CUnicodeUtils::GetUTF8(path), scratchpool, scratchpool));
597+ if (canonicalized_path == nullptr)
598+ {
599+ apr_pool_destroy(scratchpool);
600+ return false;
601+ }
572602
603+ (*((const char **) apr_array_push (targets))) = canonicalized_path;
604+
573605 err = svn_client_delete4(targets, true, false, NULL, NULL, NULL, ctx, scratchpool);
574606
575- apr_pool_destroy(scratchpool);
576-
577607 if (err)
578608 {
579609 svn_error_clear(err);
610+ apr_pool_destroy(scratchpool);
580611 return false;
581612 }
613+ apr_pool_destroy(scratchpool);
582614 return true;
583615 }
--- trunk/src/SVN/TSVNPath.cpp (revision 28528)
+++ trunk/src/SVN/TSVNPath.cpp (revision 28529)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2018 - TortoiseSVN
3+// Copyright (C) 2003-2019 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -197,12 +197,16 @@
197197 {
198198 m_sUTF8FwdslashPathEscaped = CPathUtils::PathEscape(m_sUTF8FwdslashPath);
199199 m_sUTF8FwdslashPathEscaped.Replace("file:////", "file://");
200- m_sUTF8FwdslashPathEscaped = svn_uri_canonicalize(m_sUTF8FwdslashPathEscaped, pool);
200+ const char * canonical_uri = nullptr;
201+ svn_error_clear(svn_uri_canonicalize_safe(&canonical_uri, nullptr, m_sUTF8FwdslashPathEscaped, pool, pool));
202+ m_sUTF8FwdslashPathEscaped = canonical_uri;
201203 return m_sUTF8FwdslashPathEscaped;
202204 }
203205 else
204206 {
205- m_sUTF8FwdslashPath = svn_dirent_canonicalize(m_sUTF8FwdslashPath, pool);
207+ const char * canonicalized_dirent = nullptr;
208+ svn_error_clear(svn_dirent_canonicalize_safe(&canonicalized_dirent, nullptr, m_sUTF8FwdslashPath, pool, pool));
209+ m_sUTF8FwdslashPath = canonicalized_dirent;
206210 // for UNC paths that point to the server directly (e.g., \\MYSERVER), not
207211 // to a share on the server, the svn_dirent_canonicalize() API returns
208212 // a wrong path that asserts when subversion checks that the path is absolute
--- trunk/src/Utils/PathUtils.cpp (revision 28528)
+++ trunk/src/Utils/PathUtils.cpp (revision 28529)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2018 - TortoiseSVN
3+// Copyright (C) 2003-2019 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -457,7 +457,9 @@
457457
458458 /* If the URL is already absolute, there is nothing to do. */
459459
460- const char *canonicalized_url = svn_uri_canonicalize (URL, pool);
460+ const char *canonicalized_url = nullptr;
461+ svn_error_clear(svn_uri_canonicalize_safe(&canonicalized_url, nullptr, URL, pool, pool));
462+
461463 if (svn_path_is_url (canonicalized_url))
462464 return canonicalized_url;
463465
@@ -552,17 +554,13 @@
552554
553555 if (0 == strncmp("//", URL, 2))
554556 {
555- CStringA scheme
556- = repositoryRootURL.Left (repositoryRootURL.Find (':'));
557+ CStringA scheme = repositoryRootURL.Left(repositoryRootURL.Find(':'));
557558 if (scheme.IsEmpty())
558559 return errorResult;
559560
560- return svn_uri_canonicalize ( apr_pstrcat ( pool
561- , (LPCSTR)scheme
562- , ":"
563- , (LPCSTR)URL
564- , NULL)
565- , pool);
561+ canonicalized_url = nullptr;
562+ svn_error_clear(svn_uri_canonicalize_safe(&canonicalized_url, nullptr, apr_pstrcat(pool, (LPCSTR)scheme, ":", (LPCSTR)URL, NULL), pool, pool));
563+ return canonicalized_url;
566564 }
567565
568566 /* Relative to the server root. */
Show on old repository browser