diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-11 19:08:51 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-11 19:08:51 -0400 |
| commit | 602e99e0c2f89e7214b4e1ac52215c6ae37ca5d2 (patch) | |
| tree | 2d299b6df7a494a01e027ea1680dd0fc3e5fcaeb /ws2a | |
| parent | 45c92ad49092c2a73c6400334434989bae2b666d (diff) | |
| download | webpage-602e99e0c2f89e7214b4e1ac52215c6ae37ca5d2.tar.gz webpage-602e99e0c2f89e7214b4e1ac52215c6ae37ca5d2.tar.bz2 webpage-602e99e0c2f89e7214b4e1ac52215c6ae37ca5d2.zip | |
Another try to parse newlines correctly
Diffstat (limited to 'ws2a')
| -rw-r--r-- | ws2a/bugcomment.c | 6 | ||||
| -rw-r--r-- | ws2a/testhtmlreplace.c | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/ws2a/bugcomment.c b/ws2a/bugcomment.c index 193495a..c15e6ab 100644 --- a/ws2a/bugcomment.c +++ b/ws2a/bugcomment.c @@ -21,9 +21,9 @@ char* replaceHTML(char* str){ nstrp++; }else if(str[strp] == '%'){ //printf("Hit encodeing!\n"); - int hex; - sscanf(str+strp,"%%%x",&hex); - //printf("Was:%c\n",(char)hex); + int hex = 0; + sscanf(str+strp,"%%%2x",&hex); + //printf("Was:%c(%d)\n",(char)hex,hex); if(hex == 0x0D){ strp+=3; continue; diff --git a/ws2a/testhtmlreplace.c b/ws2a/testhtmlreplace.c index 925bb6d..28b3419 100644 --- a/ws2a/testhtmlreplace.c +++ b/ws2a/testhtmlreplace.c @@ -21,9 +21,9 @@ char* replaceHTML(char* str){ nstrp++; }else if(str[strp] == '%'){ //printf("Hit encodeing!\n"); - int hex; - sscanf(str+strp,"%%%x",&hex); - //printf("Was:%c\n",(char)hex); + int hex = 0; + sscanf(str+strp,"%%%2x",&hex); + //printf("Was:%c(%d)\n",(char)hex,hex); if(hex == 0x0D){ strp+=3; continue; @@ -86,10 +86,18 @@ char* useridhash(char* str){ int main(){ char teststring[] = "This+is+a+test\nWith\nSome\nNewlines"; + printf("Original:%s\n",teststring); char* parsed = replaceHTML(teststring); printf("%s\n",parsed); + char teststring2[] = "This%0D%0Ais+another%0D%0Atest"; + printf("Original:%s\n",teststring2); char* parsed2 = replaceHTML(teststring2); printf("%s\n",parsed2); + + char teststring3[] = "This%0D%0AIs%0D%0AAnother%0D%0AMulti%0D%0ALine%0D%0AComment"; + printf("Original:%s\n",teststring3); + char* parsed3 = replaceHTML(teststring3); + printf("%s\n",parsed3); return 0; } |
