Skip to content

Commit cdb33c1

Browse files
committed
use escaping routines
1 parent c93c87c commit cdb33c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tokio-postgres/src/replication_client.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use bytes::Bytes;
77
use fallible_iterator::FallibleIterator;
88
use futures::{ready, Stream};
99
use pin_project_lite::pin_project;
10+
use postgres_protocol::escape::{escape_identifier, escape_literal};
1011
use postgres_protocol::message::backend::{Message, ReplicationMessage};
1112
use std::io;
1213
use std::marker::PhantomPinned;
@@ -103,7 +104,7 @@ impl ReplicationClient {
103104
/// show the value of the given setting
104105
pub async fn show(&self, name: &str) -> Result<String, Error> {
105106
let iclient = self.0.inner();
106-
let command = format!("SHOW \"{}\"", name);
107+
let command = format!("SHOW {}", escape_identifier(name));
107108
let buf = simple_query::encode(iclient, &command)?;
108109
let mut responses = iclient.send(RequestMessages::Single(FrontendMessage::Raw(buf)))?;
109110

@@ -151,7 +152,7 @@ impl ReplicationClient {
151152
) -> Result<ReplicationStream, Error> {
152153
let iclient = self.0.inner();
153154
let slot = match slot_name {
154-
Some(name) => format!(" SLOT \"{}\"", name),
155+
Some(name) => format!(" SLOT {}", escape_identifier(name)),
155156
None => String::from(""),
156157
};
157158
let timeline = match timeline_id {
@@ -184,13 +185,13 @@ impl ReplicationClient {
184185
options: &[(&str, &str)],
185186
) -> Result<ReplicationStream, Error> {
186187
let iclient = self.0.inner();
187-
let slot = format!(" SLOT \"{}\"", slot_name);
188+
let slot = format!(" SLOT {}", escape_identifier(slot_name));
188189
let options_string = if !options.is_empty() {
189190
format!(
190191
" ({})",
191192
options
192193
.iter()
193-
.map(|pair| format!("\"{}\" '{}'", pair.0, pair.1))
194+
.map(|pair| format!("{} {}", escape_identifier(pair.0), escape_literal(pair.1)))
194195
.collect::<Vec<String>>()
195196
.as_slice()
196197
.join(", ")

0 commit comments

Comments
 (0)