repo: uritools
action: commit
revision: 
path_from: 
revision_from: 7b51097285ff6b74176c7624fbf51498b7b7415d:
path_to: 
revision_to: 
git.thebackupbox.net
uritools
git clone git://git.thebackupbox.net/uritools
commit 7b51097285ff6b74176c7624fbf51498b7b7415d
Author: epoch 
Date:   Tue Jan 21 16:32:12 2020 +0000

    fixed uriunescape possibly missing an escaped character that landed on a boundary between two reads.

diff --git a/uriunescape.c b/uriunescape.c
index 0a7ef5dd572be35aabbbd42fec8bca192b121df7..
index ..73ceabd060890b056e4a219fd947c4daa404d738 100644
--- a/uriunescape.c
+++ b/uriunescape.c
@@ -1,10 +1,16 @@
 #include "uri.h"
 #include 
+#include 

 int main(int argc,char *argv[]) {
-  int n;
+  int i;
   int len;
-  char buf[4096];
+
+  char doh[2];
+  int hack=0;
+
+  char buf[16];
+  char buf2[16];
   if(argc > 1) {
    for(argv++,argc--;argc;argc--,argv++) {
     len=uriunescape(*argv,*argv);
@@ -12,10 +18,26 @@ int main(int argc,char *argv[]) {
     if(argc-1) write(1," ",1);
    }
   } else {
-   while((n=read(0,buf,sizeof(buf)-1)) > 0) {
-    buf[n]=0;
-    len=uriunescape(buf,buf);
-    write(1,buf,len);
+   while(fgets(buf+hack,sizeof(buf)-1-hack,stdin)) {//this is a bad idea. first chunk could end inside of a sequence we could decode. [first %] [09 second]
+    hack=0;
+    for(i=0;i<2;i++) {//2 being max length of a %XX thing.
+     if(buf[strlen(buf)-1-i] == '%') {
+      for(j=0;j

-----END OF PAGE-----