Html: Do not remove `role=` attributes from html tags [#785]

staging
gnosygnu 4 years ago
parent 3c9fd50ddc
commit ea9b592cfd

@ -1,6 +1,6 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
@ -13,8 +13,19 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.xowa.parsers.htmls.*;
package gplx.xowa.parsers.xndes;
import gplx.Bry_;
import gplx.Byte_ascii;
import gplx.Hash_adp_bry;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.core.btries.Btrie_rv;
import gplx.core.btries.Btrie_slim_mgr;
import gplx.core.primitives.Byte_obj_val;
import gplx.xowa.parsers.htmls.Mwh_atr_itm;
import gplx.xowa.parsers.htmls.Mwh_atr_itm_;
public class Xop_xatr_whitelist_mgr {
private final Hash_adp_bry grp_hash = Hash_adp_bry.cs();
private final Btrie_rv trv = new Btrie_rv();
@ -47,7 +58,9 @@ public class Xop_xatr_whitelist_mgr {
xatr.Val_bry_(gplx.xowa.parsers.amps.Xop_amp_mgr.Instance.Decode_as_bry(xatr.Val_as_bry())); // NOTE: must decode style values; "&#amp;#000000" -> "#000000"; see MW:checkCss; PAGE:en.w:Boron DATE:2015-07-29
break;
case Mwh_atr_itm_.Key_tid__role:
if (!Bry_.Eq(Val_role_presentation, xatr.Val_as_bry())) return false; // MW: For now we only support role="presentation"; DATE:2014-04-05
// 2020-08-17|ISSUE#:785|TOMBSTONE: originally put in for vertical whitespace issues in en.w:Supreme_Court_of_the_United_States, but could not reproduce
// if (!Bry_.Eq(Val_role_presentation, xatr.Val_as_bry()))
// return false; // MW: For now we only support role="presentation"; DATE:2014-04-05
break;
}
return rv;
@ -397,7 +410,6 @@ public class Xop_xatr_whitelist_mgr {
.Add_str_byte("image-set" , Style_image_set)
.Add_str_byte("/*" , Style_comment)
;
private static final byte[] Val_role_presentation = Bry_.new_a7("presentation");
}
class Xop_xatr_whitelist_itm {
public Xop_xatr_whitelist_itm(byte[] key, byte key_tid, boolean exact) {this.key = key; this.key_tid = key_tid; this.exact = exact;}

@ -1,6 +1,6 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
@ -13,8 +13,15 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import gplx.xowa.parsers.htmls.*;
package gplx.xowa.parsers.xndes;
import gplx.Bry_;
import gplx.String_;
import gplx.Tfds;
import gplx.xowa.parsers.htmls.Mwh_atr_itm;
import org.junit.Before;
import org.junit.Test;
public class Xop_xatr_whitelist_mgr_tst {
private final Xop_xatr_whitelist_fxt fxt = new Xop_xatr_whitelist_fxt();
@Before public void init() {fxt.Clear();}
@ -31,7 +38,7 @@ public class Xop_xatr_whitelist_mgr_tst {
}
@Test public void Role() {
fxt.Whitelist(Xop_xnde_tag_.Tid__div , "role" , "presentation", true);
fxt.Whitelist(Xop_xnde_tag_.Tid__div , "role" , "other", false);
fxt.Whitelist(Xop_xnde_tag_.Tid__div , "role" , "other", true);
}
@Test public void Scrub() {
fxt.Scrub_style_fail("expression");

@ -51,7 +51,7 @@ public class Pgbnr_xtn_mgr extends Xox_mgr_base implements Bfr_arg {
enabled = true;
break;
case Xow_domain_tid_.Tid__wikivoyage:
// 2020-08-16|#748:include project for en.v; PAGE:en.v:Wikivoyage:Past_events/World_Cup_2010
// 2020-08-16|ISSUE#:748|include project for en.v; PAGE:en.v:Wikivoyage:Past_events/World_Cup_2010
ns_ary = Int_ary_.New(Xow_ns_.Tid__main, Xow_ns_.Tid__user, Xow_ns_.Tid__main, Xow_ns_.Tid__project);
switch (wiki.Lang().Lang_id()) {
case Xol_lang_stub_.Id_en:

Loading…
Cancel
Save