Changeset 4930 for trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
- Timestamp:
- 09/15/09 05:41:18 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
r4315 r4930 510 510 || ''; 511 511 } 512 return 0 unless $exclusions; 513 514 my $calls_ok = Foswiki::Func::getPreferencesValue('WYSIWYG_EDITABLE_CALLS') 515 || '---'; 516 $calls_ok =~ s/\s//g; 517 518 my $ok = 1; 519 if ( $exclusions =~ /calls/ 520 && $_[0] =~ /%((?!($calls_ok){)[A-Z_]+{.*?})%/s ) 521 { 522 print STDERR "WYSIWYG_DEBUG: has calls $1 (not in $calls_ok)\n" 523 if (WHY); 524 return "Text contains calls"; 525 } 526 if ( $exclusions =~ /(macros|variables)/ && $_[0] =~ /%([A-Z_]+)%/s ) { 527 print STDERR "$exclusions WYSIWYG_DEBUG: has macros $1\n" 528 if (WHY); 529 return "Text contains macros"; 530 } 531 if ( $exclusions =~ /html/ 532 && $_[0] =~ /<\/?((?!literal|verbatim|noautolink|nop|br)\w+)/ ) 533 { 534 print STDERR "WYSIWYG_DEBUG: has html: $1\n" 535 if (WHY); 536 return "Text contains HTML"; 537 } 538 if ( $exclusions =~ /comments/ && $_[0] =~ /<[!]--/ ) { 539 print STDERR "WYSIWYG_DEBUG: has comments\n" 540 if (WHY); 541 return "Text contains comments"; 542 } 543 if ( $exclusions =~ /pre/ && $_[0] =~ /<pre\w/ ) { 544 print STDERR "WYSIWYG_DEBUG: has pre\n" 545 if (WHY); 546 return "Text contains PRE"; 547 } 512 513 # Check for explicit exclusions before generic, non-configurable 514 # purely content-related reasons for exclusion 515 if ($exclusions) { 516 my $calls_ok = Foswiki::Func::getPreferencesValue('WYSIWYG_EDITABLE_CALLS') 517 || '---'; 518 $calls_ok =~ s/\s//g; 519 520 my $ok = 1; 521 if ( $exclusions =~ /calls/ 522 && $_[0] =~ /%((?!($calls_ok){)[A-Z_]+{.*?})%/s ) 523 { 524 print STDERR "WYSIWYG_DEBUG: has calls $1 (not in $calls_ok)\n" 525 if (WHY); 526 return "Text contains calls"; 527 } 528 if ( $exclusions =~ /(macros|variables)/ && $_[0] =~ /%([A-Z_]+)%/s ) { 529 print STDERR "$exclusions WYSIWYG_DEBUG: has macros $1\n" 530 if (WHY); 531 return "Text contains macros"; 532 } 533 if ( $exclusions =~ /html/ 534 && $_[0] =~ /<\/?((?!literal|verbatim|noautolink|nop|br)\w+)/ ) 535 { 536 print STDERR "WYSIWYG_DEBUG: has html: $1\n" 537 if (WHY); 538 return "Text contains HTML"; 539 } 540 if ( $exclusions =~ /comments/ && $_[0] =~ /<[!]--/ ) { 541 print STDERR "WYSIWYG_DEBUG: has comments\n" 542 if (WHY); 543 return "Text contains comments"; 544 } 545 if ( $exclusions =~ /pre/ && $_[0] =~ /<pre\w/ ) { 546 print STDERR "WYSIWYG_DEBUG: has pre\n" 547 if (WHY); 548 return "Text contains PRE"; 549 } 550 } 551 552 # Copy the content. 553 # Then crunch verbatim blocks, because verbatim blocks may contain *anything*. 554 my $text = $_[0]; 555 556 # Look for combinations of sticky and other markup that cause problems together 557 for my $tag ('verbatim', 'literal', keys %xmltag) { 558 while ($text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi) { 559 my $inner = $1; 560 if ($inner =~ /<sticky\b[^>]*>/i) { 561 print STDERR "WYSIWYG_DEBUG: <sticky> inside <$tag>\n" 562 if (WHY); 563 return "<sticky> inside <$tag>"; 564 } 565 } 566 } 567 568 my $wasAVerbatimTag = "\000verbatim\001"; 569 while ($text =~ s/<verbatim\b[^>]*>(.*?)<\/verbatim>/$wasAVerbatimTag/i) { 570 #my $content = $1; 571 # If there is any content that breaks conversion if it is inside a verbatim block, 572 # check for it here: 573 } 574 575 # Look for combinations of verbatim and other markup that cause problems together 576 for my $tag ('literal', keys %xmltag) { 577 while ($text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi) { 578 my $inner = $1; 579 if ($inner =~ /$wasAVerbatimTag/i) { 580 print STDERR "WYSIWYG_DEBUG: <verbatim> inside <$tag>\n" 581 if (WHY); 582 return "<verbatim> inside <$tag>"; 583 } 584 } 585 } 586 587 # Look for combinations of literal and other markup that cause problems together 588 for my $tag (keys %xmltag) { 589 while ($text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi) { 590 my $inner = $1; 591 if ($inner =~ /<literal\b[^>]*>/i) { 592 print STDERR "WYSIWYG_DEBUG: <literal> inside <$tag>\n" 593 if (WHY); 594 return "<literal> inside <$tag>"; 595 } 596 } 597 } 598 548 599 return 0; 549 600 }
Note: See TracChangeset
for help on using the changeset viewer.
