Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2014 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2ea23e4f8857d088b38f to your computer and use it in GitHub Desktop.
Save anonymous/2ea23e4f8857d088b38f to your computer and use it in GitHub Desktop.
--- - 2014-11-26 15:40:00.407972085 +0900
+++ /tmp/nagiosjp-4.0.8.patch.gz.LkDFG11128 2014-11-26 15:40:00.000000000 +0900
@@ -2439,86 +2439,6 @@
an attribute. Should be <, > or
space */
#define WHERE_IN_TAG_IN_ATTRIBUTE_NAME 3 /* In the attribute name */
-@@ -1132,9 +1142,10 @@
- wchar_t *wcinput;
- wchar_t *inwcp;
- size_t mbstowcs_result;
-+ int y;
- int x;
- int where_in_tag = WHERE_OUTSIDE_TAG; /* Location in HTML tag */
-- wchar_t attr_value_start = (wchar_t)0; /* character that starts the
-+ wchar_t attr_value_start = (wchar_t)0; /* character that starts the
- attribute value */
- int tag_depth = 0; /* depth of nested HTML tags */
-
-@@ -1156,7 +1167,7 @@
- }
-
- /* Process all converted characters */
-- for( x = 0, inwcp = wcinput; x < (int)mbstowcs_result && '\0' != *inwcp;
-+ for( x = 0, inwcp = wcinput; x < (int)mbstowcs_result && '\0' != *inwcp;
- x++, inwcp++) {
-
- /* Most ASCII characters don't get encoded */
-@@ -1201,7 +1212,7 @@
- }
-
- /* Special handling for quotes */
-- else if(FALSE == escape_html_tags &&
-+ else if(FALSE == escape_html_tags &&
- ('"' == *inwcp || '\'' == *inwcp)) {
- switch(where_in_tag) {
- case WHERE_OUTSIDE_TAG:
-@@ -1228,14 +1239,14 @@
- }
- else if(attr_value_start == *inwcp) {
- /* If the quote is the same type of quote that started
-- the attribute value and it is not backslash
-+ the attribute value and it is not backslash
- escaped, it signals the end of the attribute value */
- outstp = copy_wc_to_output(*inwcp, outstp, output_max);
- where_in_tag = WHERE_IN_TAG_OUTSIDE_ATTRIBUTE;
- }
- else {
- /* If we encounter an quote that did not start the
-- attribute value and is not backslash escaped,
-+ attribute value and is not backslash escaped,
- use it as is */
- outstp = copy_wc_to_output(*inwcp, outstp, output_max);
- }
-@@ -1306,6 +1317,32 @@
- }
- }
-
-+ /***** UTF-8 MultiByte *****/
-+ // 2 Byte charactor
-+ else if( ( (unsigned char)input[x] >= 0xC0 && (unsigned char)input[x] <= 0xDF ) && ( (unsigned char)input[x+1] >= 0x80 && (unsigned char)input[x+1] <= 0xBF ) ) {
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x];
-+ }
-+ // 3 Byte charactor(BOM) : 0xEF 0xBB 0xBF
-+ else if ( ( (unsigned char)input[x] == 0xEF ) && ( (unsigned char)input[x+1] == 0xBB ) && ( (unsigned char)input[x+2] == 0xBF ) ) {
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x];
-+ }
-+ // 3 Byte charactor
-+ else if ( ( (unsigned char)input[x] >= 0xE0 ) && ( (unsigned char)input[x] <= 0xEF ) && ( (unsigned char)input[x+1] >= 0x80 ) && ( (unsigned char)input[x+1] <= 0xBF ) && ( (unsigned char)input[x+2] >= 0x80 ) && ( (unsigned char)input[x+2] <= 0xBF ) ) {
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x];
-+ }
-+ // 4 Byte charactor
-+ else if ( ( (unsigned char)input[x] >= 0xF0 ) && ( (unsigned char)input[x] <= 0xF7 ) && ( (unsigned char)input[x+1] >= 0x80 ) && ( (unsigned char)input[x+1] <= 0xBF ) && ( (unsigned char)input[x+2] >= 0x80 ) && ( (unsigned char)input[x+2] <= 0xBF ) && ( (unsigned char)input[x+3] >= 0x80 ) && ( (unsigned char)input[x+3] <= 0xBF ) ) {
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x++];
-+ encoded_html_string[y++] = input[x];
-+ }
-+
- /* for simplicity, all other chars represented by their numeric value */
- else {
- outstp = encode_character(*inwcp, outstp, output_max);
@@ -1599,27 +1636,28 @@
time(&current_time);
get_time_string(&current_time, date_time, (int)sizeof(date_time), LONG_DATE_TIME);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment