Project

General

Profile

« Previous | Next » 

Revision 2037

Added by sgarg about 20 years ago

Added subroutine for replacing characters that might create problem in HTML.
Specifically written for "being used in any text field. This create a
problem in confirmData template, when you specify input name value pair with value
having a " in it.

View differences:

register-dataset.cgi
1018 1018
    return $returnVal;
1019 1019
}
1020 1020

  
1021

  
1021 1022
################################################################################
1023
#
1024
# Subroutine for replacing characters that might create problem in HTML. 
1025
# Specifically written for " being used in any text field. This create a 
1026
# problem in confirmData template, when you specify input name value pair 
1027
# with value having a " in it.  
1028
#
1029
################################################################################
1030
sub normalizeCD{
1031
    my $val = shift;
1032

  
1033
    $val =~ s/\"/"/g;
1034
    
1035
    return $val;
1036
}
1037

  
1038

  
1039
################################################################################
1022 1040
# 
1023 1041
# Create the XML document from the HTML form input
1024 1042
# returns the XML document as a string
......
2425 2443
    }
2426 2444

  
2427 2445

  
2428
    $$templateVars{'providerGivenName'} = $FORM::providerGivenName;
2429
    $$templateVars{'providerSurName'} = $FORM::providerSurName;
2446
    $$templateVars{'providerGivenName'} = normalizeCD($FORM::providerGivenName);
2447
    $$templateVars{'providerSurName'} = normalizeCD($FORM::providerSurName);
2430 2448
    if($FORM::site eq "Select your station here."){
2431 2449
        $$templateVars{'site'} = "";
2432 2450
    }else{
......
2435 2453
    if($FORM::cfg eq "nceas"){
2436 2454
        $$templateVars{'wg'} = \@FORM::wg;
2437 2455
    }
2438
    $$templateVars{'identifier'} = $FORM::identifier;
2439
    $$templateVars{'title'} = $FORM::title;
2440
    $$templateVars{'origNamefirst0'} = $FORM::origNamefirst0;
2441
    $$templateVars{'origNamelast0'} = $FORM::origNamelast0;
2442
    $$templateVars{'origNameOrg'} = $FORM::origNameOrg;
2456
    $$templateVars{'identifier'} = normalizeCD($FORM::identifier);
2457
    $$templateVars{'title'} = normalizeCD($FORM::title);
2458
    $$templateVars{'origNamefirst0'} = normalizeCD($FORM::origNamefirst0);
2459
    $$templateVars{'origNamelast0'} = normalizeCD($FORM::origNamelast0);
2460
    $$templateVars{'origNameOrg'} = normalizeCD($FORM::origNameOrg);
2443 2461
    # $$templateVars{'origRole0'} = $FORM::origRole0;
2444
    $$templateVars{'origDelivery'} = $FORM::origDelivery;
2445
    $$templateVars{'origCity'} = $FORM::origCity;
2462
    $$templateVars{'origDelivery'} = normalizeCD($FORM::origDelivery);
2463
    $$templateVars{'origCity'} = normalizeCD($FORM::origCity);
2446 2464
    if($FORM::origState eq "Select State Here."){
2447 2465
        $$templateVars{'origState'} = "";
2448 2466
    }else{
2449 2467
        $$templateVars{'origState'} = $FORM::origState;
2450 2468
    }
2451
    $$templateVars{'origStateOther'} = $FORM::origStateOther;
2452
    $$templateVars{'origZIP'} = $FORM::origZIP;
2453
    $$templateVars{'origCountry'} = $FORM::origCountry;
2454
    $$templateVars{'origPhone'} = $FORM::origPhone;
2455
    $$templateVars{'origFAX'} = $FORM::origFAX;
2456
    $$templateVars{'origEmail'} = $FORM::origEmail;
2457
    $$templateVars{'useOrigAddress'} = $FORM::useOrigAddress;
2469
    $$templateVars{'origStateOther'} = normalizeCD($FORM::origStateOther);
2470
    $$templateVars{'origZIP'} = normalizeCD($FORM::origZIP);
2471
    $$templateVars{'origCountry'} = normalizeCD($FORM::origCountry);
2472
    $$templateVars{'origPhone'} = normalizeCD($FORM::origPhone);
2473
    $$templateVars{'origFAX'} = normalizeCD($FORM::origFAX);
2474
    $$templateVars{'origEmail'} = normalizeCD($FORM::origEmail);
2475
    $$templateVars{'useOrigAddress'} = normalizeCD($FORM::useOrigAddress);
2458 2476
    if($FORM::useOrigAddress eq "on"){
2459
        $$templateVars{'origNamefirstContact'} = $FORM::origNamefirst0;
2460
        $$templateVars{'origNamelastContact'} = $FORM::origNamelast0;
2461
        $$templateVars{'origNameOrgContact'} = $FORM::origNameOrg;
2462
        $$templateVars{'origDeliveryContact'} = $FORM::origDelivery; 
2463
        $$templateVars{'origCityContact'} = $FORM::origCity;
2477
        $$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirst0);
2478
        $$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelast0);
2479
        $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrg);
2480
        $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDelivery); 
2481
        $$templateVars{'origCityContact'} = normalizeCD($FORM::origCity);
2464 2482
        if($FORM::origState eq "Select State Here."){
2465 2483
        $$templateVars{'origStateContact'} = "";
2466 2484
        }else{
2467 2485
        $$templateVars{'origStateContact'} = $FORM::origState;
2468 2486
        }
2469
        $$templateVars{'origStateOtherContact'} = $FORM::origStateOther;
2470
        $$templateVars{'origZIPContact'} = $FORM::origZIP;
2471
        $$templateVars{'origCountryContact'} = $FORM::origCountry;
2472
        $$templateVars{'origPhoneContact'} = $FORM::origPhone;
2473
        $$templateVars{'origFAXContact'} = $FORM::origFAX;
2474
        $$templateVars{'origEmailContact'} = $FORM::origEmail;
2487
        $$templateVars{'origStateOtherContact'} = normalizeCD($FORM::origStateOther);
2488
        $$templateVars{'origZIPContact'} = normalizeCD($FORM::origZIP);
2489
        $$templateVars{'origCountryContact'} = normalizeCD($FORM::origCountry);
2490
        $$templateVars{'origPhoneContact'} = normalizeCD($FORM::origPhone);
2491
        $$templateVars{'origFAXContact'} = normalizeCD($FORM::origFAX);
2492
        $$templateVars{'origEmailContact'} = normalizeCD($FORM::origEmail);
2475 2493
    }else{
2476
        $$templateVars{'origNamefirstContact'} = $FORM::origNamefirstContact;
2477
        $$templateVars{'origNamelastContact'} = $FORM::origNamelastContact;
2478
        $$templateVars{'origNameOrgContact'} = $FORM::origNameOrgContact;
2479
        $$templateVars{'origDeliveryContact'} = $FORM::origDeliveryContact; 
2480
        $$templateVars{'origCityContact'} = $FORM::origCityContact;
2494
        $$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirstContact);
2495
        $$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelastContact);
2496
        $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrgContact);
2497
        $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDeliveryContact); 
2498
        $$templateVars{'origCityContact'} = normalizeCD($FORM::origCityContact);
2481 2499
        if($FORM::origStateContact eq "Select State Here."){
2482 2500
        $$templateVars{'origStateContact'} = "";
2483 2501
        }else{
2484 2502
        $$templateVars{'origStateContact'} = $FORM::origStateContact;
2485 2503
        }
2486
        $$templateVars{'origStateOtherContact'} = $FORM::origStateOtherContact;
2487
        $$templateVars{'origZIPContact'} = $FORM::origZIPContact;
2488
        $$templateVars{'origCountryContact'} = $FORM::origCountryContact;
2489
        $$templateVars{'origPhoneContact'} = $FORM::origPhoneContact;
2490
        $$templateVars{'origFAXContact'} = $FORM::origFAXContact;
2491
        $$templateVars{'origEmailContact'} = $FORM::origEmailContact;    
2504
        $$templateVars{'origStateOtherContact'} = normalizeCD($FORM::origStateOtherContact);
2505
        $$templateVars{'origZIPContact'} = normalizeCD($FORM::origZIPContact);
2506
        $$templateVars{'origCountryContact'} = normalizeCD($FORM::origCountryContact);
2507
        $$templateVars{'origPhoneContact'} = normalizeCD($FORM::origPhoneContact);
2508
        $$templateVars{'origFAXContact'} = normalizeCD($FORM::origFAXContact);
2509
        $$templateVars{'origEmailContact'} = normalizeCD($FORM::origEmailContact);    
2492 2510
    }
2493
    $$templateVars{'origNamefirst1'} = $FORM::origNamefirst1;
2494
    $$templateVars{'origNamelast1'} = $FORM::origNamelast1;
2511
    $$templateVars{'origNamefirst1'} = normalizeCD($FORM::origNamefirst1);
2512
    $$templateVars{'origNamelast1'} = normalizeCD($FORM::origNamelast1);
2495 2513
    if($FORM::origNamefirst1 eq "" && $FORM::origNamelast1 eq ""){
2496 2514
        $$templateVars{'origRole1'} = "";
2497 2515
    }else{
2498 2516
        $$templateVars{'origRole1'} = $FORM::origRole1;
2499 2517
    }
2500
    $$templateVars{'origNamefirst2'} = $FORM::origNamefirst2;
2501
    $$templateVars{'origNamelast2'} = $FORM::origNamelast2;
2518
    $$templateVars{'origNamefirst2'} = normalizeCD($FORM::origNamefirst2);
2519
    $$templateVars{'origNamelast2'} = normalizeCD($FORM::origNamelast2);
2502 2520
    if($FORM::origNamefirst2 eq "" && $FORM::origNamelast2 eq ""){
2503 2521
        $$templateVars{'origRole2'} = "";
2504 2522
    }else{
2505 2523
        $$templateVars{'origRole2'} = $FORM::origRole2;
2506 2524
    }
2507
    $$templateVars{'origNamefirst3'} = $FORM::origNamefirst3;
2508
    $$templateVars{'origNamelast3'} = $FORM::origNamelast3;
2525
    $$templateVars{'origNamefirst3'} = normalizeCD($FORM::origNamefirst3);
2526
    $$templateVars{'origNamelast3'} = normalizeCD($FORM::origNamelast3);
2509 2527
    if($FORM::origNamefirst3 eq "" && $FORM::origNamelast3 eq ""){
2510 2528
        $$templateVars{'origRole3'} = "";
2511 2529
    }else{
2512 2530
        $$templateVars{'origRole3'} = $FORM::origRole3;
2513 2531
    }
2514
    $$templateVars{'origNamefirst4'} = $FORM::origNamefirst4;
2515
    $$templateVars{'origNamelast4'} = $FORM::origNamelast4;
2532
    $$templateVars{'origNamefirst4'} = normalizeCD($FORM::origNamefirst4);
2533
    $$templateVars{'origNamelast4'} = normalizeCD($FORM::origNamelast4);
2516 2534
    if($FORM::origNamefirst4 eq "" && $FORM::origNamelast4 eq ""){
2517 2535
        $$templateVars{'origRole4'} = "";
2518 2536
    }else{
2519 2537
        $$templateVars{'origRole4'} = $FORM::origRole4;
2520 2538
    }
2521
    $$templateVars{'origNamefirst5'} = $FORM::origNamefirst5;
2522
    $$templateVars{'origNamelast5'} = $FORM::origNamelast5;
2539
    $$templateVars{'origNamefirst5'} = normalizeCD($FORM::origNamefirst5);
2540
    $$templateVars{'origNamelast5'} = normalizeCD($FORM::origNamelast5);
2523 2541
    if($FORM::origNamefirst5 eq "" && $FORM::origNamelast5 eq ""){
2524 2542
        $$templateVars{'origRole5'} = "";
2525 2543
    }else{
2526 2544
        $$templateVars{'origRole5'} = $FORM::origRole5;
2527 2545
    }
2528
    $$templateVars{'origNamefirst6'} = $FORM::origNamefirst6;
2529
    $$templateVars{'origNamelast6'} = $FORM::origNamelast6;
2546
    $$templateVars{'origNamefirst6'} = normalizeCD($FORM::origNamefirst6);
2547
    $$templateVars{'origNamelast6'} = normalizeCD($FORM::origNamelast6);
2530 2548
    if($FORM::origNamefirst6 eq "" && $FORM::origNamelast6 eq ""){
2531 2549
        $$templateVars{'origRole6'} = "";
2532 2550
    }else{
2533 2551
        $$templateVars{'origRole6'} = $FORM::origRole6;
2534 2552
    }
2535
    $$templateVars{'origNamefirst7'} = $FORM::origNamefirst7;
2536
    $$templateVars{'origNamelast7'} = $FORM::origNamelast7;
2553
    $$templateVars{'origNamefirst7'} = normalizeCD($FORM::origNamefirst7);
2554
    $$templateVars{'origNamelast7'} = normalizeCD($FORM::origNamelast7);
2537 2555
    if($FORM::origNamefirst7 eq "" && $FORM::origNamelast7 eq ""){
2538 2556
        $$templateVars{'origRole7'} = "";
2539 2557
    }else{
2540 2558
        $$templateVars{'origRole7'} = $FORM::origRole7;
2541 2559
    }
2542
    $$templateVars{'origNamefirst8'} = $FORM::origNamefirst8;
2543
    $$templateVars{'origNamelast8'} = $FORM::origNamelast8;
2560
    $$templateVars{'origNamefirst8'} = normalizeCD($FORM::origNamefirst8);
2561
    $$templateVars{'origNamelast8'} = normalizeCD($FORM::origNamelast8);
2544 2562
    if($FORM::origNamefirst8 eq "" && $FORM::origNamelast8 eq ""){
2545 2563
        $$templateVars{'origRole8'} = "";
2546 2564
    }else{
2547 2565
        $$templateVars{'origRole8'} = $FORM::origRole8;
2548 2566
    }
2549
    $$templateVars{'origNamefirst9'} = $FORM::origNamefirst9;
2550
    $$templateVars{'origNamelast9'} = $FORM::origNamelast9;
2567
    $$templateVars{'origNamefirst9'} = normalizeCD($FORM::origNamefirst9);
2568
    $$templateVars{'origNamelast9'} = normalizeCD($FORM::origNamelast9);
2551 2569
    if($FORM::origNamefirst9 eq "" && $FORM::origNamelast9 eq ""){
2552 2570
        $$templateVars{'origRole9'} = "";
2553 2571
    }else{
2554 2572
        $$templateVars{'origRole9'} = $FORM::origRole9;
2555 2573
    }
2556
    $$templateVars{'origNamefirst10'} = $FORM::origNamefirst10;
2557
    $$templateVars{'origNamelast10'} = $FORM::origNamelast10;
2574
    $$templateVars{'origNamefirst10'} = normalizeCD($FORM::origNamefirst10);
2575
    $$templateVars{'origNamelast10'} = normalizeCD($FORM::origNamelast10);
2558 2576
    if($FORM::origNamefirst10 eq "" && $FORM::origNamelast10 eq ""){
2559 2577
        $$templateVars{'origRole10'} = "";
2560 2578
    }else{
2561 2579
        $$templateVars{'origRole10'} = $FORM::origRole10;
2562 2580
    }
2563
    $$templateVars{'abstract'} = $FORM::abstract;
2581
    $$templateVars{'abstract'} = normalizeCD($FORM::abstract);
2564 2582
    $$templateVars{'keyCount'} = $FORM::keyCount;
2565 2583
    foreach my $kyd (param()) {
2566 2584
	if ($kyd =~ /keyword/) {
......
2571 2589
	    if ( $keyIndex =~ /[0-9]/ ){
2572 2590
		if (hasContent(param($kyd)) && hasContent(param($keyType)) && hasContent(param($keyTh))) {
2573 2591
		    debug("Registry processing keyword: $kyd = ".param($kyd)." $keyType = ".param($keyType)." $keyTh = ".param($keyTh));
2574
		    $$templateVars{$kyd} = param($kyd);
2592
		    $$templateVars{$kyd} = normalizeCD(param($kyd));
2575 2593
		    $$templateVars{$keyType} = param($keyType);
2576 2594
		    $$templateVars{$keyTh} = param($keyTh);
2577 2595
		}
2578 2596
	    }
2579 2597
	}
2580 2598
    }
2581
    $$templateVars{'addComments'} = $FORM::addComments;
2599
    $$templateVars{'addComments'} = normalizeCD($FORM::addComments);
2582 2600
    $$templateVars{'useConstraints'} = $FORM::useConstraints;
2583 2601
    $$templateVars{'useConstraintsOther'} = $FORM::useConstraintsOther;
2584 2602
    $$templateVars{'url'} = $FORM::url;
......
2587 2605
    }else{
2588 2606
        $$templateVars{'dataMedium'} = $FORM::dataMedium;
2589 2607
    }    
2590
    $$templateVars{'dataMediumOther'} = $FORM::dataMediumOther;
2608
    $$templateVars{'dataMediumOther'} = normalizeCD($FORM::dataMediumOther);
2591 2609
    $$templateVars{'beginningYear'} = $FORM::beginningYear;
2592 2610
    $$templateVars{'beginningMonth'} = $FORM::beginningMonth;
2593 2611
    $$templateVars{'beginningDay'} = $FORM::beginningDay;
2594 2612
    $$templateVars{'endingYear'} = $FORM::endingYear;
2595 2613
    $$templateVars{'endingMonth'} = $FORM::endingMonth;
2596 2614
    $$templateVars{'endingDay'} = $FORM::endingDay;
2597
    $$templateVars{'geogdesc'} = $FORM::geogdesc;
2615
    $$templateVars{'geogdesc'} = normalizeCD($FORM::geogdesc);
2598 2616
    $$templateVars{'useSiteCoord'} = $FORM::useSiteCoord;
2599 2617
    $$templateVars{'latDeg1'} = $FORM::latDeg1;
2600 2618
    $$templateVars{'latMin1'} = $FORM::latMin1;
......
2622 2640
            if ( $taxIndex =~ /[0-9]/ ){
2623 2641
                if (hasContent(param($trn)) && hasContent(param($trv))) {
2624 2642
                    debug("Registry processing taxon: $trn = ".param($trn)." $trv = ".param($trv));
2625
                    $$templateVars{$trn} = param($trn);
2626
                    $$templateVars{$trv} = param($trv);
2643
                    $$templateVars{$trn} = normalizeCD(param($trn));
2644
                    $$templateVars{$trv} = normalizeCD(param($trv));
2627 2645
                }
2628 2646
            }
2629 2647
        }
2630 2648
    }
2631
    $$templateVars{'taxaAuth'} = $FORM::taxaAuth;
2649
    $$templateVars{'taxaAuth'} = normalizeCD($FORM::taxaAuth);
2632 2650

  
2633
    $$templateVars{'methodTitle'} = $FORM::methodTitle;
2634
    $$templateVars{'methodPara'} = \@FORM::methodPara;
2635
    $$templateVars{'studyExtentDescription'} = $FORM::studyExtentDescription;
2636
    $$templateVars{'samplingDescription'} = $FORM::samplingDescription;
2651
    $$templateVars{'methodTitle'} = normalizeCD($FORM::methodTitle);
2652

  
2653
    my @tempMethodPara;
2654
    for (my $i = 0; $i < scalar(@FORM::methodPara); $i++) {
2655
	$tempMethodPara[$i] = normalizeCD($FORM::methodPara[$i]);
2656
    }
2657
    $$templateVars{'methodPara'} = \@tempMethodPara;
2658
    $$templateVars{'studyExtentDescription'} = normalizeCD($FORM::studyExtentDescription);
2659
    $$templateVars{'samplingDescription'} = normalizeCD($FORM::samplingDescription);
2637 2660
    $$templateVars{'docid'} = $FORM::docid;
2638 2661

  
2639 2662
    if (! $error) {

Also available in: Unified diff