Index: branches/REL1_17/phase3/skins/common/shared.css |
— | — | @@ -884,19 +884,6 @@ |
885 | 885 | margin: 0 0.3em; |
886 | 886 | } |
887 | 887 | |
888 | | -.grid-table { |
889 | | - display: table; |
890 | | -} |
891 | | - |
892 | | -.grid-row { |
893 | | - display: table-row; |
894 | | -} |
895 | | - |
896 | | -.grid-cell { |
897 | | - display: table-cell; |
898 | | - padding: 0.33ex; |
899 | | -} |
900 | | - |
901 | 888 | /* Localised ordered list numbering for some languages */ |
902 | 889 | ol:lang(bcc) li, |
903 | 890 | ol:lang(bqi) li, |
Index: branches/REL1_17/phase3/includes/parser/Parser.php |
— | — | @@ -797,18 +797,6 @@ |
798 | 798 | $has_opened_tr = array(); # Did this table open a <tr> element? |
799 | 799 | $indent_level = 0; # indent level of the table |
800 | 800 | |
801 | | - $table_tag = 'table'; |
802 | | - $tr_tag = 'tr'; |
803 | | - $th_tag = 'th'; |
804 | | - $td_tag = 'td'; |
805 | | - $caption_tag = 'caption'; |
806 | | - |
807 | | - $extra_table_attribs = null; |
808 | | - $extra_tr_attribs = null; |
809 | | - $extra_td_attribs = null; |
810 | | - |
811 | | - $convert_style = false; |
812 | | - |
813 | 801 | foreach ( $lines as $outLine ) { |
814 | 802 | $line = trim( $outLine ); |
815 | 803 | |
— | — | @@ -825,31 +813,9 @@ |
826 | 814 | $indent_level = strlen( $matches[1] ); |
827 | 815 | |
828 | 816 | $attributes = $this->mStripState->unstripBoth( $matches[2] ); |
| 817 | + $attributes = Sanitizer::fixTagAttributes( $attributes , 'table' ); |
829 | 818 | |
830 | | - $attr = Sanitizer::decodeTagAttributes( $attributes ); |
831 | | - |
832 | | - $mode = @$attr['mode']; |
833 | | - if ( !$mode ) $mode = 'data'; |
834 | | - |
835 | | - if ( $mode == 'grid' || $mode == 'layout' ) { |
836 | | - $table_tag = 'div'; |
837 | | - $tr_tag = 'div'; |
838 | | - $th_tag = 'div'; |
839 | | - $td_tag = 'div'; |
840 | | - $caption_tag = 'div'; |
841 | | - |
842 | | - $extra_table_attribs = array( 'class' => 'grid-table' ); |
843 | | - $extra_tr_attribs = array( 'class' => 'grid-row' ); |
844 | | - $extra_td_attribs = array( 'class' => 'grid-cell' ); |
845 | | - |
846 | | - $convert_style = true; |
847 | | - } |
848 | | - |
849 | | - if ($convert_style) $attr['style'] = Sanitizer::styleFromAttributes( $attr ); |
850 | | - $attr = Sanitizer::validateTagAttributes( $attr, $table_tag ); |
851 | | - $attributes = Sanitizer::collapseTagAttributes( $attr, $extra_table_attribs ); |
852 | | - |
853 | | - $outLine = str_repeat( '<dl><dd>' , $indent_level ) . "<$table_tag{$attributes}>"; |
| 819 | + $outLine = str_repeat( '<dl><dd>' , $indent_level ) . "<table{$attributes}>"; |
854 | 820 | array_push( $td_history , false ); |
855 | 821 | array_push( $last_tag_history , '' ); |
856 | 822 | array_push( $tr_history , false ); |
— | — | @@ -861,15 +827,15 @@ |
862 | 828 | continue; |
863 | 829 | } elseif ( substr( $line , 0 , 2 ) === '|}' ) { |
864 | 830 | # We are ending a table |
865 | | - $line = "</$table_tag>" . substr( $line , 2 ); |
| 831 | + $line = '</table>' . substr( $line , 2 ); |
866 | 832 | $last_tag = array_pop( $last_tag_history ); |
867 | 833 | |
868 | 834 | if ( !array_pop( $has_opened_tr ) ) { |
869 | | - $line = "<$tr_tag><$td_tag></$td_tag></$tr_tag>{$line}"; |
| 835 | + $line = "<tr><td></td></tr>{$line}"; |
870 | 836 | } |
871 | 837 | |
872 | 838 | if ( array_pop( $tr_history ) ) { |
873 | | - $line = "</$tr_tag>{$line}"; |
| 839 | + $line = "</tr>{$line}"; |
874 | 840 | } |
875 | 841 | |
876 | 842 | if ( array_pop( $td_history ) ) { |
— | — | @@ -883,12 +849,7 @@ |
884 | 850 | |
885 | 851 | # Whats after the tag is now only attributes |
886 | 852 | $attributes = $this->mStripState->unstripBoth( $line ); |
887 | | - |
888 | | - $attr = Sanitizer::decodeTagAttributes( $attributes ); |
889 | | - if ($convert_style) $attr['style'] = Sanitizer::styleFromAttributes( $attr ); |
890 | | - $attr = Sanitizer::validateTagAttributes( $attr, $tr_tag ); |
891 | | - $attributes = Sanitizer::collapseTagAttributes( $attr, $extra_tr_attribs ); |
892 | | - |
| 853 | + $attributes = Sanitizer::fixTagAttributes( $attributes, 'tr' ); |
893 | 854 | array_pop( $tr_attributes ); |
894 | 855 | array_push( $tr_attributes, $attributes ); |
895 | 856 | |
— | — | @@ -898,7 +859,7 @@ |
899 | 860 | array_push( $has_opened_tr , true ); |
900 | 861 | |
901 | 862 | if ( array_pop( $tr_history ) ) { |
902 | | - $line = "</$tr_tag>"; |
| 863 | + $line = '</tr>'; |
903 | 864 | } |
904 | 865 | |
905 | 866 | if ( array_pop( $td_history ) ) { |
— | — | @@ -936,7 +897,7 @@ |
937 | 898 | if ( $first_character !== '+' ) { |
938 | 899 | $tr_after = array_pop( $tr_attributes ); |
939 | 900 | if ( !array_pop( $tr_history ) ) { |
940 | | - $previous = "<$tr_tag{$tr_after}>\n"; |
| 901 | + $previous = "<tr{$tr_after}>\n"; |
941 | 902 | } |
942 | 903 | array_push( $tr_history , true ); |
943 | 904 | array_push( $tr_attributes , '' ); |
— | — | @@ -951,11 +912,11 @@ |
952 | 913 | } |
953 | 914 | |
954 | 915 | if ( $first_character === '|' ) { |
955 | | - $last_tag = $td_tag; |
| 916 | + $last_tag = 'td'; |
956 | 917 | } elseif ( $first_character === '!' ) { |
957 | | - $last_tag = $th_tag; |
| 918 | + $last_tag = 'th'; |
958 | 919 | } elseif ( $first_character === '+' ) { |
959 | | - $last_tag = $caption_tag; |
| 920 | + $last_tag = 'caption'; |
960 | 921 | } else { |
961 | 922 | $last_tag = ''; |
962 | 923 | } |
— | — | @@ -965,24 +926,15 @@ |
966 | 927 | # A cell could contain both parameters and data |
967 | 928 | $cell_data = explode( '|' , $cell , 2 ); |
968 | 929 | |
969 | | - $attributes = ''; |
970 | | - |
971 | 930 | # Bug 553: Note that a '|' inside an invalid link should not |
972 | 931 | # be mistaken as delimiting cell parameters |
973 | 932 | if ( strpos( $cell_data[0], '[[' ) !== false ) { |
974 | | - if ($extra_td_attribs) $attributes = Sanitizer::collapseTagAttributes( $extra_td_attribs ); |
975 | | - $cell = "{$previous}<{$last_tag}{$attributes}>{$cell}"; |
| 933 | + $cell = "{$previous}<{$last_tag}>{$cell}"; |
976 | 934 | } elseif ( count( $cell_data ) == 1 ) { |
977 | | - if ($extra_td_attribs) $attributes = Sanitizer::collapseTagAttributes( $extra_td_attribs ); |
978 | | - $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[0]}"; |
| 935 | + $cell = "{$previous}<{$last_tag}>{$cell_data[0]}"; |
979 | 936 | } else { |
980 | 937 | $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); |
981 | | - |
982 | | - $attr = Sanitizer::decodeTagAttributes( $attributes ); |
983 | | - if ($convert_style) $attr['style'] = Sanitizer::styleFromAttributes( $attr ); |
984 | | - $attr = Sanitizer::validateTagAttributes( $attr, $last_tag ); |
985 | | - $attributes = Sanitizer::collapseTagAttributes( $attr, $extra_td_attribs ); |
986 | | - |
| 938 | + $attributes = Sanitizer::fixTagAttributes( $attributes , $last_tag ); |
987 | 939 | $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"; |
988 | 940 | } |
989 | 941 | |
— | — | @@ -996,16 +948,16 @@ |
997 | 949 | # Closing open td, tr && table |
998 | 950 | while ( count( $td_history ) > 0 ) { |
999 | 951 | if ( array_pop( $td_history ) ) { |
1000 | | - $out .= "</$td_tag>\n"; |
| 952 | + $out .= "</td>\n"; |
1001 | 953 | } |
1002 | 954 | if ( array_pop( $tr_history ) ) { |
1003 | | - $out .= "</$tr_tag>\n"; |
| 955 | + $out .= "</tr>\n"; |
1004 | 956 | } |
1005 | 957 | if ( !array_pop( $has_opened_tr ) ) { |
1006 | | - $out .= "<$tr_tag><$td_tag></$td_tag></$tr_tag>\n" ; |
| 958 | + $out .= "<tr><td></td></tr>\n" ; |
1007 | 959 | } |
1008 | 960 | |
1009 | | - $out .= "</$table_tag>\n"; |
| 961 | + $out .= "</table>\n"; |
1010 | 962 | } |
1011 | 963 | |
1012 | 964 | # Remove trailing line-ending (b/c) |
— | — | @@ -1014,7 +966,7 @@ |
1015 | 967 | } |
1016 | 968 | |
1017 | 969 | # special case: don't return empty table |
1018 | | - if ( $out === "<$table_tag>\n<$tr_tag><$td_tag></$td_tag></$tr_tag>\n</$table_tag>" ) { |
| 970 | + if ( $out === "<table>\n<tr><td></td></tr>\n</table>" ) { |
1019 | 971 | $out = ''; |
1020 | 972 | } |
1021 | 973 | |
Index: branches/REL1_17/phase3/includes/Sanitizer.php |
— | — | @@ -796,51 +796,6 @@ |
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
800 | | - /** |
801 | | - * Take an associative array of attribute name/value pairs |
802 | | - * and generate a css style representing all the style-related |
803 | | - * attributes. If there already a style attribute in the array, |
804 | | - * it is also included in the value returned. |
805 | | - */ |
806 | | - static function styleFromAttributes( $attributes ) { |
807 | | - $styles = array(); |
808 | | - |
809 | | - foreach ( $attributes as $attribute => $value ) { |
810 | | - if ( $attribute == 'bgcolor' ) { |
811 | | - $styles[] = "background-color: $value"; |
812 | | - } else if ( $attribute == 'border' ) { |
813 | | - $styles[] = "border-width: $value"; |
814 | | - } else if ( $attribute == 'align' ) { |
815 | | - $styles[] = "text-align: $value"; |
816 | | - } else if ( $attribute == 'valign' ) { |
817 | | - $styles[] = "vertical-align: $value"; |
818 | | - } else if ( $attribute == 'width' ) { |
819 | | - if ( preg_match( '/\d+/', $value ) === false ) { |
820 | | - $value .= 'px'; |
821 | | - } |
822 | | - |
823 | | - $styles[] = "width: $value"; |
824 | | - } else if ( $attribute == 'height' ) { |
825 | | - if ( preg_match( '/\d+/', $value ) === false ) { |
826 | | - $value .= 'px'; |
827 | | - } |
828 | | - |
829 | | - $styles[] = "height: $value"; |
830 | | - } else if ( $attribute == 'nowrap' ) { |
831 | | - if ( $value ) { |
832 | | - $styles[] = "white-space: nowrap"; |
833 | | - } |
834 | | - } |
835 | | - } |
836 | | - |
837 | | - if ( isset( $attributes[ 'style' ] ) ) { |
838 | | - $styles[] = $attributes[ 'style' ]; |
839 | | - } |
840 | | - |
841 | | - if ( !$styles ) return ''; |
842 | | - else return implode( '; ', $styles ); |
843 | | - } |
844 | | - |
845 | 800 | /** |
846 | 801 | * Take a tag soup fragment listing an HTML element's attributes |
847 | 802 | * and normalize it to well-formed XML, discarding unwanted attributes. |
— | — | @@ -858,66 +813,24 @@ |
859 | 814 | * |
860 | 815 | * @param $text String |
861 | 816 | * @param $element String |
862 | | - * @param $defaults Array (optional) associative array of default attributes to splice in. |
863 | | - * class and style attributes are combined. Otherwise, values from |
864 | | - * $attributes take precedence over values from $defaults. |
865 | 817 | * @return String |
866 | 818 | */ |
867 | | - static function fixTagAttributes( $text, $element, $defaults = null ) { |
| 819 | + static function fixTagAttributes( $text, $element ) { |
868 | 820 | if( trim( $text ) == '' ) { |
869 | 821 | return ''; |
870 | 822 | } |
871 | 823 | |
872 | | - $decoded = Sanitizer::decodeTagAttributes( $text ); |
873 | | - $stripped = Sanitizer::validateTagAttributes( $decoded, $element ); |
874 | | - $attribs = Sanitizer::collapseTagAttributes( $stripped, $defaults ); |
| 824 | + $stripped = Sanitizer::validateTagAttributes( |
| 825 | + Sanitizer::decodeTagAttributes( $text ), $element ); |
875 | 826 | |
876 | | - return $attribs; |
877 | | - } |
878 | | - |
879 | | - /** |
880 | | - * Take an associative array or attribute name/value pairs |
881 | | - * and collapses it to well-formed XML. |
882 | | - * Does not filter attributes. |
883 | | - * Output is safe for further wikitext processing, with escaping of |
884 | | - * values that could trigger problems. |
885 | | - * |
886 | | - * - Double-quotes all attribute values |
887 | | - * - Prepends space if there are attributes. |
888 | | - * |
889 | | - * @param $attributes Array is an associative array of attribute name/value pairs. |
890 | | - * Assumed to be sanitized already. |
891 | | - * @param $defaults Array (optional) associative array of default attributes to splice in. |
892 | | - * class and style attributes are combined. Otherwise, values from |
893 | | - * $attributes take precedence over values from $defaults. |
894 | | - * @return String |
895 | | - */ |
896 | | - static function collapseTagAttributes( $attributes, $defaults = null ) { |
897 | | - if ( $defaults ) { |
898 | | - foreach( $defaults as $attribute => $value ) { |
899 | | - if ( isset( $attributes[ $attribute ] ) ) { |
900 | | - if ( $attribute == 'class' ) { |
901 | | - $value .= ' '. $attributes[ $attribute ]; |
902 | | - } else if ( $attribute == 'style' ) { |
903 | | - $value .= '; ' . $attributes[ $attribute ]; |
904 | | - } else { |
905 | | - continue; |
906 | | - } |
907 | | - } |
908 | | - |
909 | | - $attributes[ $attribute ] = $value; |
910 | | - } |
911 | | - } |
912 | | - |
913 | | - $chunks = array(); |
914 | | - |
915 | | - foreach( $attributes as $attribute => $value ) { |
| 827 | + $attribs = array(); |
| 828 | + foreach( $stripped as $attribute => $value ) { |
916 | 829 | $encAttribute = htmlspecialchars( $attribute ); |
917 | 830 | $encValue = Sanitizer::safeEncodeAttribute( $value ); |
918 | 831 | |
919 | | - $chunks[] = "$encAttribute=\"$encValue\""; |
| 832 | + $attribs[] = "$encAttribute=\"$encValue\""; |
920 | 833 | } |
921 | | - return count( $chunks ) ? ' ' . implode( ' ', $chunks ) : ''; |
| 834 | + return count( $attribs ) ? ' ' . implode( ' ', $attribs ) : ''; |
922 | 835 | } |
923 | 836 | |
924 | 837 | /** |