/[LeafOK_CVS]/lbbs/src/lml.c
ViewVC logotype

Diff of /lbbs/src/lml.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.12 by sysadm, Sat Jun 21 02:15:18 2025 UTC Revision 1.13 by sysadm, Wed Jul 2 04:17:33 2025 UTC
# Line 116  const static char *LML_tag_def[][3] = { Line 116  const static char *LML_tag_def[][3] = {
116          {"quote", NULL, (const char *)lml_tag_quote_filter},          {"quote", NULL, (const char *)lml_tag_quote_filter},
117          {"/quote", NULL, (const char *)lml_tag_quote_filter},          {"/quote", NULL, (const char *)lml_tag_quote_filter},
118          {"url", "", ""},          {"url", "", ""},
119          {"/url", "(链接: %s)", NULL},          {"/url", "(閾炬帴: %s)", NULL},
120          {"link", "", ""},          {"link", "", ""},
121          {"/link", "(链接: %s)", NULL},          {"/link", "(閾炬帴: %s)", NULL},
122          {"email", "", ""},          {"email", "", ""},
123          {"/email", "(Email: %s)", NULL},          {"/email", "(Email: %s)", NULL},
124          {"user", "", ""},          {"user", "", ""},
125          {"/user", "(用户: %s)", NULL},          {"/user", "(鐢ㄦ埛: %s)", NULL},
126          {"article", "", ""},          {"article", "", ""},
127          {"/article", "(文章: %s)", NULL},          {"/article", "(鏂囩珷: %s)", NULL},
128          {"image", "(图片: %s)", ""},          {"image", "(鍥剧墖: %s)", ""},
129          {"flash", "(Flash: %s)", ""},          {"flash", "(Flash: %s)", ""},
130          {"bwf", "\033[1;31m****\033[m", ""},          {"bwf", "\033[1;31m****\033[m", ""},
131  };  };
# Line 152  inline static void lml_init(void) Line 152  inline static void lml_init(void)
152    
153  int lml_plain(const char *str_in, char *str_out, int buf_len)  int lml_plain(const char *str_in, char *str_out, int buf_len)
154  {  {
155            char c;
156          char tag_param_buf[LML_TAG_PARAM_BUF_LEN];          char tag_param_buf[LML_TAG_PARAM_BUF_LEN];
157          char tag_output_buf[LML_TAG_OUTPUT_BUF_LEN];          char tag_output_buf[LML_TAG_OUTPUT_BUF_LEN];
158          int i;          int i;
# Line 315  int lml_plain(const char *str_in, char * Line 316  int lml_plain(const char *str_in, char *
316                  }                  }
317                  else if (tag_start_pos == -1) // not in LML tag                  else if (tag_start_pos == -1) // not in LML tag
318                  {                  {
319                          if (str_in[i] < 0 || str_in[i] > 127) // GBK chinese character                          if (str_in[i] & 0b10000000) // head of multi-byte character
320                          {                          {
321                                  if (j + 2 >= buf_len)                                  if (j + 4 >= buf_len) // Assuming UTF-8 CJK characters use 4 bytes, though most of them actually use 3 bytes
322                                  {                                  {
323                                          log_error("Buffer is not longer enough for output string %ld >= %d\n", j + 2, buf_len);                                          log_error("Buffer is not longer enough for output string %ld >= %d\n", j + 4, buf_len);
324                                          str_out[j] = '\0';                                          str_out[j] = '\0';
325                                          return j;                                          return j;
326                                  }                                  }
327                                  str_out[j++] = str_in[i++];  
328                                  if (str_in[i] == '\0')                                  c = (str_in[i] & 0b01110000) << 1;
329                                    while (c & 0b10000000)
330                                  {                                  {
331                                          str_out[j] = '\0';                                          str_out[j++] = str_in[i++];
332                                          return j;                                          if (str_in[i] == '\0')
333                                            {
334                                                    str_out[j] = '\0';
335                                                    return j;
336                                            }
337                                            c = (c & 0b01111111) << 1;
338                                  }                                  }
339                          }                          }
340    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1