Skip to content

Commit 03943a5

Browse files
Fix potential bug with DB name escaping for URL when requesting replication-related API (#498)
1 parent 608bc2e commit 03943a5

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Add replication V2 option for database creation
1111
- Use Go 1.20.3 for testing. Add govulncheck to pipeline
1212
- Fix test for extended names
13+
- Fix potential bug with DB name escaping for URL when requesting replication-related API
1314

1415
## [1.5.2](https://github.com/arangodb/go-driver/tree/v1.5.2) (2023-03-01)
1516
- Bump `DRIVER_VERSION`

cluster_impl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (c *cluster) Health(ctx context.Context) (ClusterHealth, error) {
6666

6767
// DatabaseInventory Get the inventory of the cluster containing all collections (with entire details) of a database.
6868
func (c *cluster) DatabaseInventory(ctx context.Context, db Database) (DatabaseInventory, error) {
69-
req, err := c.conn.NewRequest("GET", path.Join("_db", db.Name(), "_api/replication/clusterInventory"))
69+
req, err := c.conn.NewRequest("GET", path.Join("_db", pathEscape(db.Name()), "_api/replication/clusterInventory"))
7070
if err != nil {
7171
return DatabaseInventory{}, WithStack(err)
7272
}

replication_impl.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var ErrBatchClosed = errors.New("Batch already closed")
5050

5151
// CreateBatch creates a "batch" to prevent WAL file removal and to take a snapshot
5252
func (c *client) CreateBatch(ctx context.Context, db Database, serverID int64, ttl time.Duration) (Batch, error) {
53-
req, err := c.conn.NewRequest("POST", path.Join("_db", db.Name(), "_api/replication/batch"))
53+
req, err := c.conn.NewRequest("POST", path.Join("_db", pathEscape(db.Name()), "_api/replication/batch"))
5454
if err != nil {
5555
return nil, WithStack(err)
5656
}
@@ -81,7 +81,7 @@ func (c *client) CreateBatch(ctx context.Context, db Database, serverID int64, t
8181

8282
// DatabaseInventory Get the inventory of a server containing all collections (with entire details) of a database.
8383
func (c *client) DatabaseInventory(ctx context.Context, db Database) (DatabaseInventory, error) {
84-
req, err := c.conn.NewRequest("GET", path.Join("_db", db.Name(), "_api/replication/inventory"))
84+
req, err := c.conn.NewRequest("GET", path.Join("_db", pathEscape(db.Name()), "_api/replication/inventory"))
8585
if err != nil {
8686
return DatabaseInventory{}, WithStack(err)
8787
}

revision.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (n *RevisionUInt64) MarshalVPack() (velocypack.Slice, error) {
167167
// GetRevisionTree retrieves the Revision tree (Merkel tree) associated with the collection.
168168
func (c *client) GetRevisionTree(ctx context.Context, db Database, batchId, collection string) (RevisionTree, error) {
169169

170-
req, err := c.conn.NewRequest("GET", path.Join("_db", db.Name(), "_api/replication/revisions/tree"))
170+
req, err := c.conn.NewRequest("GET", path.Join("_db", pathEscape(db.Name()), "_api/replication/revisions/tree"))
171171
if err != nil {
172172
return RevisionTree{}, WithStack(err)
173173
}
@@ -196,7 +196,7 @@ func (c *client) GetRevisionTree(ctx context.Context, db Database, batchId, coll
196196
func (c *client) GetRevisionsByRanges(ctx context.Context, db Database, batchId, collection string,
197197
minMaxRevision []RevisionMinMax, resume RevisionUInt64) (RevisionRanges, error) {
198198

199-
req, err := c.conn.NewRequest("PUT", path.Join("_db", db.Name(), "_api/replication/revisions/ranges"))
199+
req, err := c.conn.NewRequest("PUT", path.Join("_db", pathEscape(db.Name()), "_api/replication/revisions/ranges"))
200200
if err != nil {
201201
return RevisionRanges{}, WithStack(err)
202202
}
@@ -233,7 +233,7 @@ func (c *client) GetRevisionsByRanges(ctx context.Context, db Database, batchId,
233233
func (c *client) GetRevisionDocuments(ctx context.Context, db Database, batchId, collection string,
234234
revisions Revisions) ([]map[string]interface{}, error) {
235235

236-
req, err := c.conn.NewRequest("PUT", path.Join("_db", db.Name(), "_api/replication/revisions/documents"))
236+
req, err := c.conn.NewRequest("PUT", path.Join("_db", pathEscape(db.Name()), "_api/replication/revisions/documents"))
237237
if err != nil {
238238
return nil, WithStack(err)
239239
}

0 commit comments

Comments
 (0)