rugged 1.3.2.3 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +1 -1
- data/ext/rugged/rugged_config.c +7 -2
- data/ext/rugged/rugged_remote.c +17 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +103 -276
- data/vendor/libgit2/COPYING +36 -19
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
- data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +288 -975
- data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
- data/vendor/libgit2/deps/zlib/deflate.c +31 -83
- data/vendor/libgit2/deps/zlib/deflate.h +15 -12
- data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
- data/vendor/libgit2/deps/zlib/infback.c +1 -2
- data/vendor/libgit2/deps/zlib/inffast.c +14 -14
- data/vendor/libgit2/deps/zlib/inflate.c +8 -39
- data/vendor/libgit2/deps/zlib/inflate.h +2 -3
- data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
- data/vendor/libgit2/deps/zlib/trees.c +48 -27
- data/vendor/libgit2/deps/zlib/zlib.h +100 -126
- data/vendor/libgit2/deps/zlib/zutil.c +2 -2
- data/vendor/libgit2/deps/zlib/zutil.h +9 -12
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +11 -2
- data/vendor/libgit2/include/git2/blame.h +4 -1
- data/vendor/libgit2/include/git2/blob.h +14 -1
- data/vendor/libgit2/include/git2/branch.h +2 -0
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +5 -2
- data/vendor/libgit2/include/git2/clone.h +3 -3
- data/vendor/libgit2/include/git2/commit.h +2 -0
- data/vendor/libgit2/include/git2/common.h +5 -12
- data/vendor/libgit2/include/git2/config.h +19 -3
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +1 -1
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +17 -9
- data/vendor/libgit2/include/git2/email.h +1 -1
- data/vendor/libgit2/include/git2/errors.h +1 -2
- data/vendor/libgit2/include/git2/filter.h +7 -2
- data/vendor/libgit2/include/git2/graph.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +11 -5
- data/vendor/libgit2/include/git2/indexer.h +19 -0
- data/vendor/libgit2/include/git2/merge.h +23 -3
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/object.h +23 -0
- data/vendor/libgit2/include/git2/odb.h +37 -7
- data/vendor/libgit2/include/git2/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +9 -1
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +184 -37
- data/vendor/libgit2/include/git2/repository.h +14 -9
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +3 -3
- data/vendor/libgit2/include/git2/status.h +9 -3
- data/vendor/libgit2/include/git2/submodule.h +7 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
- data/vendor/libgit2/include/git2/sys/remote.h +31 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +25 -34
- data/vendor/libgit2/include/git2/tag.h +1 -0
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +7 -7
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +12 -2
- data/vendor/libgit2/src/CMakeLists.txt +189 -315
- data/vendor/libgit2/src/annotated_commit.h +1 -1
- data/vendor/libgit2/src/apply.c +18 -18
- data/vendor/libgit2/src/apply.h +2 -2
- data/vendor/libgit2/src/attr.c +18 -18
- data/vendor/libgit2/src/attr_file.c +17 -17
- data/vendor/libgit2/src/attr_file.h +4 -4
- data/vendor/libgit2/src/attrcache.c +17 -12
- data/vendor/libgit2/src/blame_git.c +1 -1
- data/vendor/libgit2/src/blob.c +33 -26
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +150 -109
- data/vendor/libgit2/src/branch.h +15 -3
- data/vendor/libgit2/src/buf.c +126 -0
- data/vendor/libgit2/src/buf.h +50 -0
- data/vendor/libgit2/src/cc-compat.h +1 -1
- data/vendor/libgit2/src/checkout.c +74 -68
- data/vendor/libgit2/src/cherrypick.c +10 -10
- data/vendor/libgit2/src/clone.c +66 -66
- data/vendor/libgit2/src/commit.c +128 -58
- data/vendor/libgit2/src/commit.h +24 -1
- data/vendor/libgit2/src/commit_graph.c +68 -53
- data/vendor/libgit2/src/commit_graph.h +10 -3
- data/vendor/libgit2/src/commit_list.c +2 -3
- data/vendor/libgit2/src/common.h +10 -3
- data/vendor/libgit2/src/config.c +99 -77
- data/vendor/libgit2/src/config.h +15 -2
- data/vendor/libgit2/src/config_file.c +103 -91
- data/vendor/libgit2/src/config_mem.c +9 -9
- data/vendor/libgit2/src/config_parse.c +27 -23
- data/vendor/libgit2/src/crlf.c +24 -21
- data/vendor/libgit2/src/date.c +10 -17
- data/vendor/libgit2/src/date.h +33 -0
- data/vendor/libgit2/src/describe.c +27 -19
- data/vendor/libgit2/src/diff.c +25 -8
- data/vendor/libgit2/src/diff.h +2 -4
- data/vendor/libgit2/src/diff_driver.c +34 -36
- data/vendor/libgit2/src/diff_driver.h +3 -3
- data/vendor/libgit2/src/diff_file.c +29 -20
- data/vendor/libgit2/src/diff_generate.c +30 -6
- data/vendor/libgit2/src/diff_generate.h +5 -3
- data/vendor/libgit2/src/diff_print.c +102 -95
- data/vendor/libgit2/src/diff_stats.c +40 -29
- data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +3 -8
- data/vendor/libgit2/src/email.c +54 -38
- data/vendor/libgit2/src/email.h +1 -1
- data/vendor/libgit2/src/errors.c +18 -18
- data/vendor/libgit2/src/features.h.in +6 -1
- data/vendor/libgit2/src/fetch.c +69 -24
- data/vendor/libgit2/src/fetch.h +1 -1
- data/vendor/libgit2/src/fetchhead.c +19 -19
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +96 -52
- data/vendor/libgit2/src/filter.h +26 -5
- data/vendor/libgit2/src/fs_path.c +1912 -0
- data/vendor/libgit2/src/fs_path.h +752 -0
- data/vendor/libgit2/src/futils.c +91 -85
- data/vendor/libgit2/src/futils.h +26 -14
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
- data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
- data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
- data/vendor/libgit2/src/hash/sha1.h +3 -1
- data/vendor/libgit2/src/hash.c +67 -35
- data/vendor/libgit2/src/hash.h +12 -12
- data/vendor/libgit2/src/ident.c +18 -18
- data/vendor/libgit2/src/ignore.c +35 -34
- data/vendor/libgit2/src/ignore.h +2 -2
- data/vendor/libgit2/src/index.c +79 -80
- data/vendor/libgit2/src/index.h +6 -3
- data/vendor/libgit2/src/indexer.c +75 -57
- data/vendor/libgit2/src/iterator.c +64 -56
- data/vendor/libgit2/src/iterator.h +5 -5
- data/vendor/libgit2/src/khash.h +1 -1
- data/vendor/libgit2/src/libgit2.c +22 -19
- data/vendor/libgit2/src/mailmap.c +38 -36
- data/vendor/libgit2/src/merge.c +27 -27
- data/vendor/libgit2/src/merge.h +1 -14
- data/vendor/libgit2/src/merge_driver.c +2 -2
- data/vendor/libgit2/src/merge_file.c +13 -3
- data/vendor/libgit2/src/message.c +21 -10
- data/vendor/libgit2/src/midx.c +83 -66
- data/vendor/libgit2/src/midx.h +3 -3
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/net.c +278 -68
- data/vendor/libgit2/src/net.h +10 -3
- data/vendor/libgit2/src/netops.c +1 -1
- data/vendor/libgit2/src/netops.h +1 -1
- data/vendor/libgit2/src/notes.c +20 -29
- data/vendor/libgit2/src/object.c +49 -9
- data/vendor/libgit2/src/object.h +1 -1
- data/vendor/libgit2/src/odb.c +35 -32
- data/vendor/libgit2/src/odb.h +1 -1
- data/vendor/libgit2/src/odb_loose.c +68 -68
- data/vendor/libgit2/src/odb_mempack.c +18 -5
- data/vendor/libgit2/src/odb_pack.c +43 -43
- data/vendor/libgit2/src/oid.c +11 -4
- data/vendor/libgit2/src/oid.h +15 -0
- data/vendor/libgit2/src/pack-objects.c +41 -26
- data/vendor/libgit2/src/pack-objects.h +11 -6
- data/vendor/libgit2/src/pack.c +10 -10
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch.h +1 -0
- data/vendor/libgit2/src/patch_generate.c +27 -11
- data/vendor/libgit2/src/patch_generate.h +5 -5
- data/vendor/libgit2/src/patch_parse.c +24 -24
- data/vendor/libgit2/src/path.c +76 -1951
- data/vendor/libgit2/src/path.h +34 -741
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/pathspec.h +2 -2
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.h +1 -1
- data/vendor/libgit2/src/proxy.c +4 -1
- data/vendor/libgit2/src/proxy.h +1 -1
- data/vendor/libgit2/src/push.c +30 -35
- data/vendor/libgit2/src/push.h +4 -16
- data/vendor/libgit2/src/rand.c +226 -0
- data/vendor/libgit2/src/rand.h +37 -0
- data/vendor/libgit2/src/reader.c +8 -8
- data/vendor/libgit2/src/reader.h +2 -2
- data/vendor/libgit2/src/rebase.c +89 -88
- data/vendor/libgit2/src/refdb_fs.c +447 -173
- data/vendor/libgit2/src/refs.c +32 -32
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +32 -37
- data/vendor/libgit2/src/refspec.h +5 -2
- data/vendor/libgit2/src/regexp.c +1 -1
- data/vendor/libgit2/src/remote.c +713 -419
- data/vendor/libgit2/src/remote.h +15 -10
- data/vendor/libgit2/src/repository.c +350 -467
- data/vendor/libgit2/src/repository.h +11 -10
- data/vendor/libgit2/src/reset.c +8 -5
- data/vendor/libgit2/src/revert.c +10 -10
- data/vendor/libgit2/src/revparse.c +48 -35
- data/vendor/libgit2/src/revwalk.c +7 -7
- data/vendor/libgit2/src/signature.c +12 -6
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +1 -1
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +36 -37
- data/vendor/libgit2/src/status.c +4 -1
- data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
- data/vendor/libgit2/src/str.h +357 -0
- data/vendor/libgit2/src/streams/mbedtls.c +8 -6
- data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
- data/vendor/libgit2/src/submodule.c +171 -159
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +68 -52
- data/vendor/libgit2/src/sysdir.h +15 -10
- data/vendor/libgit2/src/tag.c +29 -27
- data/vendor/libgit2/src/thread.h +3 -3
- data/vendor/libgit2/src/threadstate.c +3 -3
- data/vendor/libgit2/src/threadstate.h +1 -1
- data/vendor/libgit2/src/trace.c +1 -14
- data/vendor/libgit2/src/trace.h +5 -22
- data/vendor/libgit2/src/trailer.c +1 -1
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transport.c +10 -10
- data/vendor/libgit2/src/transports/auth.c +7 -9
- data/vendor/libgit2/src/transports/auth.h +2 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/transports/git.c +9 -11
- data/vendor/libgit2/src/transports/http.c +37 -17
- data/vendor/libgit2/src/transports/http.h +2 -3
- data/vendor/libgit2/src/transports/httpclient.c +65 -65
- data/vendor/libgit2/src/transports/local.c +124 -116
- data/vendor/libgit2/src/transports/smart.c +51 -139
- data/vendor/libgit2/src/transports/smart.h +25 -31
- data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
- data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
- data/vendor/libgit2/src/transports/ssh.c +47 -112
- data/vendor/libgit2/src/transports/winhttp.c +50 -56
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree-cache.h +2 -2
- data/vendor/libgit2/src/tree.c +59 -48
- data/vendor/libgit2/src/tree.h +1 -1
- data/vendor/libgit2/src/unix/map.c +0 -2
- data/vendor/libgit2/src/unix/posix.h +1 -4
- data/vendor/libgit2/src/unix/realpath.c +0 -2
- data/vendor/libgit2/src/util.c +14 -14
- data/vendor/libgit2/src/util.h +2 -28
- data/vendor/libgit2/src/vector.h +1 -1
- data/vendor/libgit2/src/win32/findfile.c +172 -116
- data/vendor/libgit2/src/win32/findfile.h +7 -4
- data/vendor/libgit2/src/win32/path_w32.c +140 -9
- data/vendor/libgit2/src/win32/path_w32.h +2 -0
- data/vendor/libgit2/src/win32/posix.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +11 -27
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
- data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
- data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/worktree.c +116 -94
- data/vendor/libgit2/src/worktree.h +1 -1
- data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
- data/vendor/libgit2/src/xdiff/xemit.c +23 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
- data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
- data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
- data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
- data/vendor/libgit2/src/xdiff/xutils.c +18 -7
- data/vendor/libgit2/src/zstream.c +5 -5
- data/vendor/libgit2/src/zstream.h +4 -4
- metadata +25 -10
- data/vendor/libgit2/src/buffer.h +0 -374
data/vendor/libgit2/src/net.c
CHANGED
@@ -9,10 +9,9 @@
|
|
9
9
|
#include "netops.h"
|
10
10
|
|
11
11
|
#include <ctype.h>
|
12
|
-
#include "git2/errors.h"
|
13
12
|
|
14
13
|
#include "posix.h"
|
15
|
-
#include "
|
14
|
+
#include "str.h"
|
16
15
|
#include "http_parser.h"
|
17
16
|
#include "runtime.h"
|
18
17
|
|
@@ -21,6 +20,24 @@
|
|
21
20
|
#define DEFAULT_PORT_GIT "9418"
|
22
21
|
#define DEFAULT_PORT_SSH "22"
|
23
22
|
|
23
|
+
bool git_net_str_is_url(const char *str)
|
24
|
+
{
|
25
|
+
const char *c;
|
26
|
+
|
27
|
+
for (c = str; *c; c++) {
|
28
|
+
if (*c == ':' && *(c+1) == '/' && *(c+2) == '/')
|
29
|
+
return true;
|
30
|
+
|
31
|
+
if ((*c < 'a' || *c > 'z') &&
|
32
|
+
(*c < 'A' || *c > 'Z') &&
|
33
|
+
(*c < '0' || *c > '9') &&
|
34
|
+
(*c != '+' && *c != '-' && *c != '.'))
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
24
41
|
static const char *default_port_for_scheme(const char *scheme)
|
25
42
|
{
|
26
43
|
if (strcmp(scheme, "http") == 0)
|
@@ -29,7 +46,9 @@ static const char *default_port_for_scheme(const char *scheme)
|
|
29
46
|
return DEFAULT_PORT_HTTPS;
|
30
47
|
else if (strcmp(scheme, "git") == 0)
|
31
48
|
return DEFAULT_PORT_GIT;
|
32
|
-
else if (strcmp(scheme, "ssh") == 0
|
49
|
+
else if (strcmp(scheme, "ssh") == 0 ||
|
50
|
+
strcmp(scheme, "ssh+git") == 0 ||
|
51
|
+
strcmp(scheme, "git+ssh") == 0)
|
33
52
|
return DEFAULT_PORT_SSH;
|
34
53
|
|
35
54
|
return NULL;
|
@@ -79,13 +98,13 @@ int git_net_url_parse(git_net_url *url, const char *given)
|
|
79
98
|
{
|
80
99
|
struct http_parser_url u = {0};
|
81
100
|
bool has_scheme, has_host, has_port, has_path, has_query, has_userinfo;
|
82
|
-
|
83
|
-
host =
|
84
|
-
port =
|
85
|
-
path =
|
86
|
-
username =
|
87
|
-
password =
|
88
|
-
query =
|
101
|
+
git_str scheme = GIT_STR_INIT,
|
102
|
+
host = GIT_STR_INIT,
|
103
|
+
port = GIT_STR_INIT,
|
104
|
+
path = GIT_STR_INIT,
|
105
|
+
username = GIT_STR_INIT,
|
106
|
+
password = GIT_STR_INIT,
|
107
|
+
query = GIT_STR_INIT;
|
89
108
|
int error = GIT_EINVALIDSPEC;
|
90
109
|
|
91
110
|
if (http_parser_parse_url(given, strlen(given), false, &u)) {
|
@@ -103,7 +122,7 @@ int git_net_url_parse(git_net_url *url, const char *given)
|
|
103
122
|
if (has_scheme) {
|
104
123
|
const char *url_scheme = given + u.field_data[UF_SCHEMA].off;
|
105
124
|
size_t url_scheme_len = u.field_data[UF_SCHEMA].len;
|
106
|
-
|
125
|
+
git_str_put(&scheme, url_scheme, url_scheme_len);
|
107
126
|
git__strntolower(scheme.ptr, scheme.size);
|
108
127
|
} else {
|
109
128
|
git_error_set(GIT_ERROR_NET, "malformed URL '%s'", given);
|
@@ -113,13 +132,13 @@ int git_net_url_parse(git_net_url *url, const char *given)
|
|
113
132
|
if (has_host) {
|
114
133
|
const char *url_host = given + u.field_data[UF_HOST].off;
|
115
134
|
size_t url_host_len = u.field_data[UF_HOST].len;
|
116
|
-
|
135
|
+
git_str_decode_percent(&host, url_host, url_host_len);
|
117
136
|
}
|
118
137
|
|
119
138
|
if (has_port) {
|
120
139
|
const char *url_port = given + u.field_data[UF_PORT].off;
|
121
140
|
size_t url_port_len = u.field_data[UF_PORT].len;
|
122
|
-
|
141
|
+
git_str_put(&port, url_port, url_port_len);
|
123
142
|
} else {
|
124
143
|
const char *default_port = default_port_for_scheme(scheme.ptr);
|
125
144
|
|
@@ -128,21 +147,21 @@ int git_net_url_parse(git_net_url *url, const char *given)
|
|
128
147
|
goto done;
|
129
148
|
}
|
130
149
|
|
131
|
-
|
150
|
+
git_str_puts(&port, default_port);
|
132
151
|
}
|
133
152
|
|
134
153
|
if (has_path) {
|
135
154
|
const char *url_path = given + u.field_data[UF_PATH].off;
|
136
155
|
size_t url_path_len = u.field_data[UF_PATH].len;
|
137
|
-
|
156
|
+
git_str_put(&path, url_path, url_path_len);
|
138
157
|
} else {
|
139
|
-
|
158
|
+
git_str_puts(&path, "/");
|
140
159
|
}
|
141
160
|
|
142
161
|
if (has_query) {
|
143
162
|
const char *url_query = given + u.field_data[UF_QUERY].off;
|
144
163
|
size_t url_query_len = u.field_data[UF_QUERY].len;
|
145
|
-
|
164
|
+
git_str_decode_percent(&query, url_query, url_query_len);
|
146
165
|
}
|
147
166
|
|
148
167
|
if (has_userinfo) {
|
@@ -156,49 +175,238 @@ int git_net_url_parse(git_net_url *url, const char *given)
|
|
156
175
|
const char *url_password = colon + 1;
|
157
176
|
size_t url_password_len = url_userinfo_len - (url_username_len + 1);
|
158
177
|
|
159
|
-
|
160
|
-
|
178
|
+
git_str_decode_percent(&username, url_username, url_username_len);
|
179
|
+
git_str_decode_percent(&password, url_password, url_password_len);
|
161
180
|
} else {
|
162
|
-
|
181
|
+
git_str_decode_percent(&username, url_userinfo, url_userinfo_len);
|
163
182
|
}
|
164
183
|
}
|
165
184
|
|
166
|
-
if (
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
185
|
+
if (git_str_oom(&scheme) ||
|
186
|
+
git_str_oom(&host) ||
|
187
|
+
git_str_oom(&port) ||
|
188
|
+
git_str_oom(&path) ||
|
189
|
+
git_str_oom(&query) ||
|
190
|
+
git_str_oom(&username) ||
|
191
|
+
git_str_oom(&password))
|
173
192
|
return -1;
|
174
193
|
|
175
|
-
url->scheme =
|
176
|
-
url->host =
|
177
|
-
url->port =
|
178
|
-
url->path =
|
179
|
-
url->query =
|
180
|
-
url->username =
|
181
|
-
url->password =
|
194
|
+
url->scheme = git_str_detach(&scheme);
|
195
|
+
url->host = git_str_detach(&host);
|
196
|
+
url->port = git_str_detach(&port);
|
197
|
+
url->path = git_str_detach(&path);
|
198
|
+
url->query = git_str_detach(&query);
|
199
|
+
url->username = git_str_detach(&username);
|
200
|
+
url->password = git_str_detach(&password);
|
182
201
|
|
183
202
|
error = 0;
|
184
203
|
|
185
204
|
done:
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
205
|
+
git_str_dispose(&scheme);
|
206
|
+
git_str_dispose(&host);
|
207
|
+
git_str_dispose(&port);
|
208
|
+
git_str_dispose(&path);
|
209
|
+
git_str_dispose(&query);
|
210
|
+
git_str_dispose(&username);
|
211
|
+
git_str_dispose(&password);
|
193
212
|
return error;
|
194
213
|
}
|
195
214
|
|
215
|
+
static int scp_invalid(const char *message)
|
216
|
+
{
|
217
|
+
git_error_set(GIT_ERROR_NET, "invalid scp-style path: %s", message);
|
218
|
+
return GIT_EINVALIDSPEC;
|
219
|
+
}
|
220
|
+
|
221
|
+
static bool is_ipv6(const char *str)
|
222
|
+
{
|
223
|
+
const char *c;
|
224
|
+
size_t colons = 0;
|
225
|
+
|
226
|
+
if (*str++ != '[')
|
227
|
+
return false;
|
228
|
+
|
229
|
+
for (c = str; *c; c++) {
|
230
|
+
if (*c == ':')
|
231
|
+
colons++;
|
232
|
+
|
233
|
+
if (*c == ']')
|
234
|
+
return (colons > 1);
|
235
|
+
|
236
|
+
if (*c != ':' &&
|
237
|
+
(*c < '0' || *c > '9') &&
|
238
|
+
(*c < 'a' || *c > 'f') &&
|
239
|
+
(*c < 'A' || *c > 'F'))
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
|
243
|
+
return false;
|
244
|
+
}
|
245
|
+
|
246
|
+
static bool has_at(const char *str)
|
247
|
+
{
|
248
|
+
const char *c;
|
249
|
+
|
250
|
+
for (c = str; *c; c++) {
|
251
|
+
if (*c == '@')
|
252
|
+
return true;
|
253
|
+
|
254
|
+
if (*c == ':')
|
255
|
+
break;
|
256
|
+
}
|
257
|
+
|
258
|
+
return false;
|
259
|
+
}
|
260
|
+
|
261
|
+
int git_net_url_parse_scp(git_net_url *url, const char *given)
|
262
|
+
{
|
263
|
+
const char *default_port = default_port_for_scheme("ssh");
|
264
|
+
const char *c, *user, *host, *port, *path = NULL;
|
265
|
+
size_t user_len = 0, host_len = 0, port_len = 0;
|
266
|
+
unsigned short bracket = 0;
|
267
|
+
|
268
|
+
enum {
|
269
|
+
NONE,
|
270
|
+
USER,
|
271
|
+
HOST_START, HOST, HOST_END,
|
272
|
+
IPV6, IPV6_END,
|
273
|
+
PORT_START, PORT, PORT_END,
|
274
|
+
PATH_START
|
275
|
+
} state = NONE;
|
276
|
+
|
277
|
+
memset(url, 0, sizeof(git_net_url));
|
278
|
+
|
279
|
+
for (c = given; *c && !path; c++) {
|
280
|
+
switch (state) {
|
281
|
+
case NONE:
|
282
|
+
switch (*c) {
|
283
|
+
case '@':
|
284
|
+
return scp_invalid("unexpected '@'");
|
285
|
+
case ':':
|
286
|
+
return scp_invalid("unexpected ':'");
|
287
|
+
case '[':
|
288
|
+
if (is_ipv6(c)) {
|
289
|
+
state = IPV6;
|
290
|
+
host = c;
|
291
|
+
} else if (bracket++ > 1) {
|
292
|
+
return scp_invalid("unexpected '['");
|
293
|
+
}
|
294
|
+
break;
|
295
|
+
default:
|
296
|
+
if (has_at(c)) {
|
297
|
+
state = USER;
|
298
|
+
user = c;
|
299
|
+
} else {
|
300
|
+
state = HOST;
|
301
|
+
host = c;
|
302
|
+
}
|
303
|
+
break;
|
304
|
+
}
|
305
|
+
break;
|
306
|
+
|
307
|
+
case USER:
|
308
|
+
if (*c == '@') {
|
309
|
+
user_len = (c - user);
|
310
|
+
state = HOST_START;
|
311
|
+
}
|
312
|
+
break;
|
313
|
+
|
314
|
+
case HOST_START:
|
315
|
+
state = (*c == '[') ? IPV6 : HOST;
|
316
|
+
host = c;
|
317
|
+
break;
|
318
|
+
|
319
|
+
case HOST:
|
320
|
+
if (*c == ':') {
|
321
|
+
host_len = (c - host);
|
322
|
+
state = bracket ? PORT_START : PATH_START;
|
323
|
+
} else if (*c == ']') {
|
324
|
+
if (bracket-- == 0)
|
325
|
+
return scp_invalid("unexpected ']'");
|
326
|
+
|
327
|
+
host_len = (c - host);
|
328
|
+
state = HOST_END;
|
329
|
+
}
|
330
|
+
break;
|
331
|
+
|
332
|
+
case HOST_END:
|
333
|
+
if (*c != ':')
|
334
|
+
return scp_invalid("unexpected character after hostname");
|
335
|
+
state = PATH_START;
|
336
|
+
break;
|
337
|
+
|
338
|
+
case IPV6:
|
339
|
+
if (*c == ']')
|
340
|
+
state = IPV6_END;
|
341
|
+
break;
|
342
|
+
|
343
|
+
case IPV6_END:
|
344
|
+
if (*c != ':')
|
345
|
+
return scp_invalid("unexpected character after ipv6 address");
|
346
|
+
|
347
|
+
host_len = (c - host);
|
348
|
+
state = bracket ? PORT_START : PATH_START;
|
349
|
+
break;
|
350
|
+
|
351
|
+
case PORT_START:
|
352
|
+
port = c;
|
353
|
+
state = PORT;
|
354
|
+
break;
|
355
|
+
|
356
|
+
case PORT:
|
357
|
+
if (*c == ']') {
|
358
|
+
if (bracket-- == 0)
|
359
|
+
return scp_invalid("unexpected ']'");
|
360
|
+
|
361
|
+
port_len = c - port;
|
362
|
+
state = PORT_END;
|
363
|
+
}
|
364
|
+
break;
|
365
|
+
|
366
|
+
case PORT_END:
|
367
|
+
if (*c != ':')
|
368
|
+
return scp_invalid("unexpected character after ipv6 address");
|
369
|
+
|
370
|
+
state = PATH_START;
|
371
|
+
break;
|
372
|
+
|
373
|
+
case PATH_START:
|
374
|
+
path = c;
|
375
|
+
break;
|
376
|
+
|
377
|
+
default:
|
378
|
+
GIT_ASSERT("unhandled state");
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
if (!path)
|
383
|
+
return scp_invalid("path is required");
|
384
|
+
|
385
|
+
GIT_ERROR_CHECK_ALLOC(url->scheme = git__strdup("ssh"));
|
386
|
+
|
387
|
+
if (user_len)
|
388
|
+
GIT_ERROR_CHECK_ALLOC(url->username = git__strndup(user, user_len));
|
389
|
+
|
390
|
+
GIT_ASSERT(host_len);
|
391
|
+
GIT_ERROR_CHECK_ALLOC(url->host = git__strndup(host, host_len));
|
392
|
+
|
393
|
+
if (port_len)
|
394
|
+
GIT_ERROR_CHECK_ALLOC(url->port = git__strndup(port, port_len));
|
395
|
+
else
|
396
|
+
GIT_ERROR_CHECK_ALLOC(url->port = git__strdup(default_port));
|
397
|
+
|
398
|
+
GIT_ASSERT(path);
|
399
|
+
GIT_ERROR_CHECK_ALLOC(url->path = git__strdup(path));
|
400
|
+
|
401
|
+
return 0;
|
402
|
+
}
|
403
|
+
|
196
404
|
int git_net_url_joinpath(
|
197
405
|
git_net_url *out,
|
198
406
|
git_net_url *one,
|
199
407
|
const char *two)
|
200
408
|
{
|
201
|
-
|
409
|
+
git_str path = GIT_STR_INIT;
|
202
410
|
const char *query;
|
203
411
|
size_t one_len, two_len;
|
204
412
|
|
@@ -226,14 +434,14 @@ int git_net_url_joinpath(
|
|
226
434
|
two_len--;
|
227
435
|
}
|
228
436
|
|
229
|
-
|
230
|
-
|
231
|
-
|
437
|
+
git_str_put(&path, one->path, one_len);
|
438
|
+
git_str_putc(&path, '/');
|
439
|
+
git_str_put(&path, two, two_len);
|
232
440
|
|
233
|
-
if (
|
441
|
+
if (git_str_oom(&path))
|
234
442
|
return -1;
|
235
443
|
|
236
|
-
out->path =
|
444
|
+
out->path = git_str_detach(&path);
|
237
445
|
|
238
446
|
if (one->scheme) {
|
239
447
|
out->scheme = git__strdup(one->scheme);
|
@@ -316,6 +524,7 @@ static void remove_service_suffix(
|
|
316
524
|
int git_net_url_apply_redirect(
|
317
525
|
git_net_url *url,
|
318
526
|
const char *redirect_location,
|
527
|
+
bool allow_offsite,
|
319
528
|
const char *service_suffix)
|
320
529
|
{
|
321
530
|
git_net_url tmp = GIT_NET_URL_INIT;
|
@@ -340,8 +549,8 @@ int git_net_url_apply_redirect(
|
|
340
549
|
/* Validate that this is a legal redirection */
|
341
550
|
|
342
551
|
if (original->scheme &&
|
343
|
-
|
344
|
-
|
552
|
+
strcmp(original->scheme, tmp.scheme) != 0 &&
|
553
|
+
strcmp(tmp.scheme, "https") != 0) {
|
345
554
|
git_error_set(GIT_ERROR_NET, "cannot redirect from '%s' to '%s'",
|
346
555
|
original->scheme, tmp.scheme);
|
347
556
|
|
@@ -350,6 +559,7 @@ int git_net_url_apply_redirect(
|
|
350
559
|
}
|
351
560
|
|
352
561
|
if (original->host &&
|
562
|
+
!allow_offsite &&
|
353
563
|
git__strcasecmp(original->host, tmp.host) != 0) {
|
354
564
|
git_error_set(GIT_ERROR_NET, "cannot redirect from '%s' to '%s'",
|
355
565
|
original->host, tmp.host);
|
@@ -399,53 +609,53 @@ void git_net_url_swap(git_net_url *a, git_net_url *b)
|
|
399
609
|
memcpy(b, &tmp, sizeof(git_net_url));
|
400
610
|
}
|
401
611
|
|
402
|
-
int git_net_url_fmt(
|
612
|
+
int git_net_url_fmt(git_str *buf, git_net_url *url)
|
403
613
|
{
|
404
614
|
GIT_ASSERT_ARG(url);
|
405
615
|
GIT_ASSERT_ARG(url->scheme);
|
406
616
|
GIT_ASSERT_ARG(url->host);
|
407
617
|
|
408
|
-
|
409
|
-
|
618
|
+
git_str_puts(buf, url->scheme);
|
619
|
+
git_str_puts(buf, "://");
|
410
620
|
|
411
621
|
if (url->username) {
|
412
|
-
|
622
|
+
git_str_puts(buf, url->username);
|
413
623
|
|
414
624
|
if (url->password) {
|
415
|
-
|
416
|
-
|
625
|
+
git_str_puts(buf, ":");
|
626
|
+
git_str_puts(buf, url->password);
|
417
627
|
}
|
418
628
|
|
419
|
-
|
629
|
+
git_str_putc(buf, '@');
|
420
630
|
}
|
421
631
|
|
422
|
-
|
632
|
+
git_str_puts(buf, url->host);
|
423
633
|
|
424
634
|
if (url->port && !git_net_url_is_default_port(url)) {
|
425
|
-
|
426
|
-
|
635
|
+
git_str_putc(buf, ':');
|
636
|
+
git_str_puts(buf, url->port);
|
427
637
|
}
|
428
638
|
|
429
|
-
|
639
|
+
git_str_puts(buf, url->path ? url->path : "/");
|
430
640
|
|
431
641
|
if (url->query) {
|
432
|
-
|
433
|
-
|
642
|
+
git_str_putc(buf, '?');
|
643
|
+
git_str_puts(buf, url->query);
|
434
644
|
}
|
435
645
|
|
436
|
-
return
|
646
|
+
return git_str_oom(buf) ? -1 : 0;
|
437
647
|
}
|
438
648
|
|
439
|
-
int git_net_url_fmt_path(
|
649
|
+
int git_net_url_fmt_path(git_str *buf, git_net_url *url)
|
440
650
|
{
|
441
|
-
|
651
|
+
git_str_puts(buf, url->path ? url->path : "/");
|
442
652
|
|
443
653
|
if (url->query) {
|
444
|
-
|
445
|
-
|
654
|
+
git_str_putc(buf, '?');
|
655
|
+
git_str_puts(buf, url->query);
|
446
656
|
}
|
447
657
|
|
448
|
-
return
|
658
|
+
return git_str_oom(buf) ? -1 : 0;
|
449
659
|
}
|
450
660
|
|
451
661
|
static bool matches_pattern(
|
data/vendor/libgit2/src/net.h
CHANGED
@@ -21,12 +21,18 @@ typedef struct git_net_url {
|
|
21
21
|
|
22
22
|
#define GIT_NET_URL_INIT { NULL }
|
23
23
|
|
24
|
+
/** Is a given string a url? */
|
25
|
+
extern bool git_net_str_is_url(const char *str);
|
26
|
+
|
24
27
|
/** Duplicate a URL */
|
25
28
|
extern int git_net_url_dup(git_net_url *out, git_net_url *in);
|
26
29
|
|
27
|
-
/** Parses a string containing a URL into a structure.
|
30
|
+
/** Parses a string containing a URL into a structure. */
|
28
31
|
extern int git_net_url_parse(git_net_url *url, const char *str);
|
29
32
|
|
33
|
+
/** Parses a string containing an SCP style path into a URL structure. */
|
34
|
+
extern int git_net_url_parse_scp(git_net_url *url, const char *str);
|
35
|
+
|
30
36
|
/** Appends a path and/or query string to the given URL */
|
31
37
|
extern int git_net_url_joinpath(
|
32
38
|
git_net_url *out,
|
@@ -46,16 +52,17 @@ extern bool git_net_url_is_ipv6(git_net_url *url);
|
|
46
52
|
extern int git_net_url_apply_redirect(
|
47
53
|
git_net_url *url,
|
48
54
|
const char *redirect_location,
|
55
|
+
bool allow_offsite,
|
49
56
|
const char *service_suffix);
|
50
57
|
|
51
58
|
/** Swaps the contents of one URL for another. */
|
52
59
|
extern void git_net_url_swap(git_net_url *a, git_net_url *b);
|
53
60
|
|
54
61
|
/** Places the URL into the given buffer. */
|
55
|
-
extern int git_net_url_fmt(
|
62
|
+
extern int git_net_url_fmt(git_str *out, git_net_url *url);
|
56
63
|
|
57
64
|
/** Place the path and query string into the given buffer. */
|
58
|
-
extern int git_net_url_fmt_path(
|
65
|
+
extern int git_net_url_fmt_path(git_str *buf, git_net_url *url);
|
59
66
|
|
60
67
|
/** Determines if the url matches given pattern or pattern list */
|
61
68
|
extern bool git_net_url_matches_pattern(
|
data/vendor/libgit2/src/netops.c
CHANGED