ÃÑ ÆäÀÌÁö ¼ö : 3224
![]()
|
Facebook Joinc ±×·ì
Joinc QA »çÀÌÆ®
![]()
Tweet
joinc´Â Firefox¿Í chrome¿¡¼ Å×½ºÆ® Çß½À´Ï´Ù. IE¿¡¼´Â Å×À̺íÀÌ ±úÁö°Å³ª À̹ÌÁö°¡ º¸ÀÌÁö ¾ÊÀ» ¼ö ÀÖ½À´Ï´Ù. ƯÈ÷ ±¸±Û DocsÀ̹ÌÁöÀÇ °æ¿ì ¿¢¹Úó¸®µÉ ¼ö ÀÖ½À´Ï´Ù. ¼³¸í
GETȤÀº POST¹æ½ÄÀ¸·Î Àü´ÞµÇ´Â URL ¹®ÀÚ¿À» ÀÎÄÚµùÇϰųª µðÄÚµù ÇÑ´Ù.
Ŭ¶óÀÌ¾ðÆ®¿¡¼ À§ÀÇ ¹æ¹ýÀ» ÀÌ¿ëÇØ¼ µ¥ÀÌÅ͸¦ Àü´ÞÇÒ °æ¿ì¿¡, [a-zA-Z0-9\-_\.] ÀÌ¿ÜÀÇ ¸ðµç ´Ü¾î´Â %HEX¹æ½ÄÀ¸·Î ÀÎÄÚµùµÇ¾î¼ Àü´ÞµÈ´Ù. ¼¹öÃø¿¡¼´Â À̸¦ ´Ù½Ã µðÄÚµùÇØ¾ß ÇÑ´Ù. CGI(12) ÇÁ·Î±×·¡¹ÖÀ» ÇÑ´Ù¸é ¹Ýµå½Ã ÀÎÄÚµù/µðÄÚµù°úÁ¤À» °ÅÃÄ¾ß ÇÑ´Ù.
ÀÎÄÚµù ¹æ½Ä¿¡ ´ëÇÑ ³»¿ëÀº CGI ÇÁ·Î±×·¡¹ÖÀ» Âü°íÇϱ⠹ٶõ´Ù. »ç¿ë¹æ¹ýint urlencode(unsigned char *str, unsigned char *dest); int urldecode(unsigned char *str, unsigned char *dest);strÀ» ÀÎÄÚµùÇϰųª µðÄÚµùÇØ¼ dest¿¡ º¹»çÇÑ´Ù. ¸®ÅϰªÀº ÀÎÄÚµù/µðÄÚµù °á°ú µ¥ÀÌÅÍÀÇ ±æÀÌ´Ù.
»ç¿ë¿¹ int main() { int i, n; unsigned char dest[256] = {0x00,}; unsigned char test[256] = {0x00,}; unsigned char *str = "hello world ¾È³çÇϼ¼¿ä\n"; unsigned char *str2 = "hello\%20world\%20\%be\%c8"; printf("Original : %d %s", strlen(str), str2); n = urlencode(str, dest); printf("decode : %d %s\n", n, dest); n = urldecode(str2, test); printf("encode : %d %s\n", n, test); } ÄÚµå#include <stdio.h> #include <string.h> #include <unistd.h> /* * urldecode * ÀÔ·ÂµÈ source¸¦ urldecodeÇØ¼ dest¿¡ º¹»çÇÑ´Ù. * */ int urldecode(unsigned char *source, unsigned char *dest) { int num=0, i, hexv, index=0; int retval=0; while(*source) { if (*source == '%') { num = 0; retval = 0; for (i = 0; i < 2; i++) { *source++; if (*(source) < ':') { num = *(source) - 48; } else if (*(source) > '@' && *(source) < '[') { num = (*(source) - 'A')+10; } else { num = (*(source) - 'a')+10; } if ((16*(1-i))) num = (num*16); retval += num; } dest[index] = retval; index++; } else { dest[index] = *source; index++; } *source++; } return index; } int urlencode(unsigned char *source, unsigned char *dest) { unsigned char hex[4]; unsigned char *sbuf; int size = 0; sbuf = dest; while(*source) { if ((*source > 47 && *source < 57) || (*source > 64 && *source < 92) || (*source > 96 && *source < 123) || *source == '-' || *source == '.' || *source == '_') { *sbuf = *source; } else { sprintf(hex, "%%%02X", *source); strncat(sbuf, hex,3); *sbuf++; *sbuf++; size += 2; } *source++; *sbuf++; size++; } return size; } |
|
|
EmailÀ» ±âÀÔÇϸé, ´ñ±ÛÀÌ ¸ÞÀÏ·Î Àü´ÞµË´Ï´Ù. |
|