From 66ebe18f5505a19cf887deb245de684c715f774b Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Mon, 14 Apr 2014 14:39:53 +0000 Subject: [PATCH] Fixed bug in escape function, return data length in ebx. git-svn-id: svn://kolibrios.org@4831 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/libraries/http/http.asm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/programs/develop/libraries/http/http.asm b/programs/develop/libraries/http/http.asm index d64751b999..68372e66de 100644 --- a/programs/develop/libraries/http/http.asm +++ b/programs/develop/libraries/http/http.asm @@ -1118,15 +1118,19 @@ endp ;;================================================================================================;; -proc URI_escape URI ;/////////////////////////////////////////////////////////////////////////////;; +proc HTTP_escape URI ;////////////////////////////////////////////////////////////////////////////;; ;;------------------------------------------------------------------------------------------------;; ;? ;; ;;------------------------------------------------------------------------------------------------;; ;> URI = ptr to ASCIIZ URI ;; ;;------------------------------------------------------------------------------------------------;; -;< eax = 0 (error) / ptr to ASCIIZ URI ;; +;< eax = 0 (error) / ptr to ASCIIZ URI/data ;; +;< ebx = length of escaped URI/data ;; ;;================================================================================================;; + +; TODO: instead of static buffer allocation, make it 4096 bytes and larger only if needed + pusha invoke mem.alloc, URLMAXLEN @@ -1145,7 +1149,8 @@ proc URI_escape URI ;/////////////////////////////////////////////////////////// mov cl, al and cl, 0x1f mov bl, al - shr bl, 5 + shr bl, 3 + and bl, not 3 bt dword[bits_must_escape + ebx], ecx jc .escape @@ -1168,6 +1173,9 @@ proc URI_escape URI ;/////////////////////////////////////////////////////////// .done: stosb + sub edi, [esp + 7 * 4] + dec edi + mov [esp + 4 * 4], edi popa ret @@ -1182,7 +1190,7 @@ endp ;;================================================================================================;; -proc URI_unescape URI ;///////////////////////////////////////////////////////////////////////////;; +proc HTTP_unescape URI ;//////////////////////////////////////////////////////////////////////////;; ;;------------------------------------------------------------------------------------------------;; ;? ;; ;;------------------------------------------------------------------------------------------------;; @@ -1687,8 +1695,8 @@ export \ HTTP_process , 'process' , \ HTTP_free , 'free' , \ HTTP_stop , 'stop' , \ - URI_escape , 'escape' , \ - URI_unescape , 'unescape' + HTTP_escape , 'escape' , \ + HTTP_unescape , 'unescape' ; HTTP_put , 'put' , \ ; HTTP_delete , 'delete' , \