[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middlewa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middleware. |
Date: |
Tue, 13 Dec 2022 02:59:47 -0500 (EST) |
branch: elpa/emacsql
commit ab53199d07a28219986ef9453836d53478d4f5e8
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Fix escaping issue in middleware.
---
sqlite/emacsql.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/sqlite/emacsql.c b/sqlite/emacsql.c
index 7e4e680d59..3fcc5655b1 100644
--- a/sqlite/emacsql.c
+++ b/sqlite/emacsql.c
@@ -6,28 +6,30 @@
#define TRUE 1
#define FALSE 0
-char *dup(const char *s) {
- char *copy = malloc(strlen(s));
- while (*s) {
- *copy = *s;
- copy++;
- s++;
+char* escape(const char *message) {
+ int count = 0, length_orig = strlen(message);
+ for (int i = 0; i < length_orig; i++) {
+ if (message[i] == '"') {
+ count++;
+ }
}
- return copy;
-}
-
-char *escape(char *message) {
+ char *copy = malloc(length_orig + count + 1);
+ char *p = copy;
while (*message) {
if (*message == '"') {
- *message = '\'';
+ *p = '\\';
+ p++;
}
+ *p = *message;
message++;
+ p++;
}
- return message;
+ *p = '\0';
+ return copy;
}
void send_error(int code, const char *message) {
- char *escaped = escape(dup(message));
+ char *escaped = escape(message);
printf("error %d \"%s\"\n", code, escaped);
free(escaped);
}
- [nongnu] elpa/emacsql 749becb017 181/427: Disable notices and warnings in psql., (continued)
- [nongnu] elpa/emacsql 749becb017 181/427: Disable notices and warnings in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e42d939235 187/427: In SQLite, block for up to 30 seconds on db lock., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3ba9109d45 198/427: Start using real version numbers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql de0bde9a02 207/427: Use Cask package-file directive instead., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb3dbfc891 213/427: Set a global query timeout., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 394bb062aa 219/427: Add a small library for determining binary to use., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dc2afbbc1f 221/427: Adjust the Emacsql wire protocol., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6318472b20 223/427: Link the Makefiles together., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a7728339ba 216/427: Switch to custom middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middleware.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1146f2e26a 233/427: Flesh out the changes in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed77eac846 237/427: Add string prepared statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847196cafa 226/427: Set tty to raw in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3e5ce21b0d 242/427: Tweak the new implementation notes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a459708684 244/427: Move tests into their own directory., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4db068920d 247/427: Provide MySQL front-end., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dce6736e04 249/427: Oops, add new MySQL module to the Makefile., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fcba876d0e 251/427: Solve the tty (pty) issue in MySQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fb0e2d5423 256/427: Fix typecase typo., ELPA Syncer, 2022/12/13