Project

General

Profile

« Previous | Next » 

Revision 2339

Added by sgarg over 19 years ago

Made changes to fix bug# 1538. Changed the code of the normalize function in MetaCatUtil.java. Earlier code was not taking care of characters above 123.

In DBSAXHandler.java, added call to normalize function before text is written to db.

View differences:

MetaCatUtil.java
243 243
    {
244 244
        StringBuffer str = new StringBuffer();
245 245

  
246
        int len = (s != null) ? s.length() : 0;
247
        for (int i = 0; i < len; i++) {
248
            char ch = s.charAt(i);
249
            switch (ch) {
250
            case '<':
251
                {
252
                    str.append("&lt;");
253
                    break;
254
                }
255
            case '>':
256
                {
257
                    str.append("&gt;");
258
                    break;
259
                }
260
            case '&':
261
                {
262
                    str.append("&amp;");
263
                    break;
264
                }
265
            case '"':
266
                {
267
                    str.append("&quot;");
268
                    break;
269
                }
270
            case '\r':
271
            case '\n':
272
                {
273
                    // else, default append char
274
                }
275
            default:
276
                {
277
                    str.append(ch);
278
                }
279
            }
280
        }
281
        return (str.toString());
246
             int len = (s != null) ? s.length() : 0;
247
             for (int i = 0; i < len; i++) {
248
                 char ch = s.charAt(i);
249
                 switch (ch) {
250
                     case '<': {
251
                         str.append("&lt;");
252
                         break;
253
                     }
254
                     case '>': {
255
                         str.append("&gt;");
256
                         break;
257
                     }
258
                     case '&': {
259
                         str.append("&amp;");
260
                         break;
261
                     }
262
                     case '"': {
263
                         str.append("&quot;");
264
                         break;
265
                     }
266
                     default: {
267
                         if ((ch<128)&&(ch>31)) {
268
                             str.append(ch);
269
                         }
270
                         else if (ch<32) {
271
                             if (ch== 10) {
272
                                 str.append(ch);
273
                             }
274
                             if (ch==13) {
275
                                 str.append(ch);
276
                             }
277
                             if (ch==9) {
278
                                 str.append(ch);
279
                             }
280
                             // otherwise skip
281
                         }
282
                         else {
283
                             str.append("&#");
284
                             str.append(Integer.toString(ch));
285
                             str.append(';');
286
                         }
287
                     }
288
                 }
289
             }
290
             String temp = str.toString();
291
             temp = temp.trim();
292
             if (temp.length()<1) temp = " ";
293
             return temp;
282 294
    }
283 295

  
284 296
    /**

Also available in: Unified diff