git-svn: trunk@3372
Tomasz Kojm authored on 2007/12/06 23:53:22... | ... |
@@ -430,7 +430,11 @@ static inline void html_tag_set_inahref(tag_arguments_t *tags,int idx,int in_ahr |
430 | 430 |
static inline void html_tag_contents_append(tag_arguments_t *tags,int idx,const unsigned char* begin,const unsigned char *end) |
431 | 431 |
{ |
432 | 432 |
if(end && (begin<end)) { |
433 |
- blobAddData(tags->contents[idx-1],begin,end-begin); |
|
433 |
+ const size_t blob_len = blobGetDataSize(tags->contents[idx-1]); |
|
434 |
+ const size_t blob_sizeleft = blob_len <= MAX_TAG_CONTENTS_LENGTH ? (MAX_TAG_CONTENTS_LENGTH - blob_len) : 0; |
|
435 |
+ const size_t str_len = end - begin; |
|
436 |
+ if(blob_sizeleft) |
|
437 |
+ blobAddData(tags->contents[idx-1],begin, blob_sizeleft < str_len ? blob_sizeleft : str_len ); |
|
434 | 438 |
} |
435 | 439 |
} |
436 | 440 |
|
... | ... |
@@ -442,15 +446,6 @@ static inline void html_tag_contents_done(tag_arguments_t *tags,int idx) |
442 | 442 |
blobClose(tags->contents[idx-1]); |
443 | 443 |
} |
444 | 444 |
|
445 |
-static inline void html_tag_contents_length_check(tag_arguments_t *tags,int* idx) |
|
446 |
-{ |
|
447 |
- if (blobGetDataSize(tags->contents[*idx-1])>MAX_TAG_CONTENTS_LENGTH) { |
|
448 |
- html_tag_contents_done(tags,*idx); |
|
449 |
- *idx=0;/*in_ahref=0;*/ |
|
450 |
- } |
|
451 |
-} |
|
452 |
- |
|
453 |
- |
|
454 | 445 |
static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag_arguments_t *hrefs,const struct cli_dconf* dconf) |
455 | 446 |
{ |
456 | 447 |
int fd_tmp, tag_length, tag_arg_length, binary; |
... | ... |
@@ -645,7 +640,6 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
645 | 645 |
if(hrefs && hrefs->scanContents && in_ahref && href_contents_begin) { |
646 | 646 |
/*append this text portion to the contents of <a>*/ |
647 | 647 |
html_tag_contents_append(hrefs,in_ahref,href_contents_begin,ptr); |
648 |
- html_tag_contents_length_check(hrefs,&in_ahref); |
|
649 | 648 |
href_contents_begin=NULL;/*We just encountered another tag inside <a>, so skip it*/ |
650 | 649 |
} |
651 | 650 |
ptr++; |