Project

General

Profile

« Previous | Next » 

Revision 894

Added by berkley almost 23 years ago

fixed bug with ampersands in the returned relations in the resultset.

View differences:

src/edu/ucsb/nceas/metacat/AuthLdap.java
208 208
        catch(javax.naming.ReferralException re) 
209 209
        {
210 210
          System.out.println("referral during authentication");
211
	  try
211
	        try
212 212
          {
213 213
            refExc = re;
214 214
            Thread t = new Thread(this);
src/edu/ucsb/nceas/metacat/DBQuery.java
444 444
            String subDT = rs.getString(4);
445 445
            String objDT = rs.getString(5);
446 446
            
447
            //MetacatURL murl = new MetacatURL(sub);
448
            //we only want to process metacat urls here.
449
            //if (murl.getProtocol().equals("metacat")) {
450
              //String[] tempparam = murl.getParam(0);
451
              //if (tempparam[0].equals("docid") && tempparam[1].equals(docidkey))
452
              //{
453
                document = new StringBuffer();
454
                document.append("<triple>");
455
                document.append("<subject>").append(sub);
456
                document.append("</subject>");
457
                //if (!subDT.equals("null")) {
458
                if ( subDT != null ) {
459
                  document.append("<subjectdoctype>").append(subDT);
460
                  document.append("</subjectdoctype>");
461
                }
462
                document.append("<relationship>").append(rel);
463
                document.append("</relationship>");
464
                document.append("<object>").append(obj);
465
                document.append("</object>");
466
                //if (!objDT.equals("null")) {
467
                if ( objDT != null ) {
468
                  document.append("<objectdoctype>").append(objDT);
469
                  document.append("</objectdoctype>");
470
                }
471
                document.append("</triple>");
472
                
473
                String removedelement = (String)docListResult.remove(docidkey);
474
                docListResult.put(docidkey, removedelement + 
475
                                  document.toString());
476
                
477
              //}
478
            //}
447
            document = new StringBuffer();
448
            document.append("<triple>");
449
            document.append("<subject>").append(MetaCatUtil.normalize(sub));
450
            document.append("</subject>");
451
            if ( subDT != null ) {
452
              document.append("<subjectdoctype>").append(subDT);
453
              document.append("</subjectdoctype>");
454
            }
455
            document.append("<relationship>").append(MetaCatUtil.normalize(rel));
456
            document.append("</relationship>");
457
            document.append("<object>").append(MetaCatUtil.normalize(obj));
458
            document.append("</object>");
459
            if ( objDT != null ) {
460
              document.append("<objectdoctype>").append(objDT);
461
              document.append("</objectdoctype>");
462
            }
463
            document.append("</triple>");
464
            
465
            String removedelement = (String)docListResult.remove(docidkey);
466
            docListResult.put(docidkey, removedelement + 
467
                              document.toString());
479 468
            tableHasRows = rs.next();
480 469
          }
481 470
          rs.close();
src/edu/ucsb/nceas/metacat/MetaCatUtil.java
405 405
    }
406 406
    return options;
407 407
  }
408
  
409
  /** Normalizes the given string. Taken from configXML.java*/
410
  public static String normalize(String s)
411
  {
412
    StringBuffer str = new StringBuffer();
413

  
414
    int len = (s != null) ? s.length() : 0;
415
    for (int i = 0; i < len; i++)
416
    {
417
      char ch = s.charAt(i);
418
      switch (ch)
419
      {
420
      case '<':
421
      {
422
        str.append("&lt;");
423
        break;
424
      }
425
        case '>':
426
      {
427
        str.append("&gt;");
428
        break;
429
      }
430
      case '&':
431
      {
432
        str.append("&amp;");
433
        break;
434
      }
435
      case '"':
436
      {
437
        str.append("&quot;");
438
        break;
439
      }
440
      case '\r':
441
      case '\n':
442
      {
443
        // else, default append char
444
      }
445
      default:
446
      {
447
        str.append(ch);
448
      }
449
      }
450
    }
451
    return (str.toString());
452
  } 
453
  
408 454
}

Also available in: Unified diff