mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -189,7 +189,7 @@ class TstObj implements SrlMgr {
|
||||
public int SrlIntOr(String key, int v) {Atrs_add(key, v, IntClassXtn._); return v;}
|
||||
public long SrlLongOr(String key, long v) {Atrs_add(key, v, LongClassXtn._); return v;}
|
||||
public String SrlStrOr(String key, String v) {Atrs_add(key, v, StringClassXtn._); return v;}
|
||||
public DecimalAdp SrlDecimalOr(String key, DecimalAdp v) {Atrs_add(key, v, DecimalAdpClassXtn._); return v;}
|
||||
public Decimal_adp SrlDecimalOr(String key, Decimal_adp v) {Atrs_add(key, v, DecimalAdpClassXtn._); return v;}
|
||||
public DateAdp SrlDateOr(String key, DateAdp v) {Atrs_add(key, v, DateAdpClassXtn._); return v;}
|
||||
public double SrlDoubleOr(String key, double v) {Atrs_add(key, v, DoubleClassXtn._); return v;}
|
||||
public Object SrlObjOr(String key, Object v) {
|
||||
|
||||
@@ -94,6 +94,13 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
}
|
||||
public static Xoa_ttl parse_(Xowe_wiki wiki, byte[] raw) {return new_(wiki, wiki.Appe().Msg_log(), raw, 0, raw.length);}
|
||||
private static final Object thread_lock = new Object();
|
||||
// $dbkey = preg_replace( '/\xE2\x80[\x8E\x8F\xAA-\xAE]/S', '', $dbkey );
|
||||
// $dbkey = preg_replace( '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u', '_', $dbkey );
|
||||
private static final int Char__bidi = 1, Char__ws = 2;
|
||||
private static final Btrie_slim_mgr char_trie = Btrie_slim_mgr.cs()
|
||||
.Add_many_int(Char__bidi , "\u00E2\u0080\u008E", "\u00E2\u0080\u008F", "\u00E2\u0080\u00AA", "\u00E2\u0080\u00AB", "\u00E2\u0080\u00AC", "\u00E2\u0080\u00AD", "\u00E2\u0080\u00AE")
|
||||
.Add_many_int(Char__ws , "\u00A0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u2028", "\u2029", "\u202F", "\u205F", "\u3000")
|
||||
;
|
||||
public static Xoa_ttl new_(Xowe_wiki wiki, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
Bry_bfr_mkr bry_mkr = app.Utl__bfr_mkr();
|
||||
@@ -120,7 +127,6 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
FUTURE:
|
||||
- "/", "a/" (should be page); "#" (not a page)
|
||||
- Talk:Help:a disallowed; Category talk:Help:a allowed
|
||||
- forbid extended ws: '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u'
|
||||
- remove invalid characters $rxTc
|
||||
- forbid ./ /.
|
||||
- forbid ~~~
|
||||
@@ -217,7 +223,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
cur = match_pos; // set cur after ";"
|
||||
continue;
|
||||
case Byte_ascii.Amp:
|
||||
b_ary = Byte_ascii.Amp_bry; // NTOE: if & convert to &; PAGE:en.w:Amadou Bagayoko?redirect=n; DATE:2014-09-23
|
||||
b_ary = Byte_ascii.Amp_bry; // NOTE: if & convert to &; PAGE:en.w:Amadou Bagayoko?redirect=n; DATE:2014-09-23
|
||||
break;
|
||||
case Byte_ascii.Quote:
|
||||
case Byte_ascii.Lt:
|
||||
@@ -233,7 +239,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
b_ary = amp_itm.Utf8_bry();
|
||||
b_ary = amp_itm.U8_bry();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -294,21 +300,23 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Bidi_0_E2:
|
||||
if (cur + 2 < end) {
|
||||
if ( src[cur + 1] == Bidi_1_80) {
|
||||
switch (src[cur + 2]) {
|
||||
case Bidi_2_8E: case Bidi_2_8F: case Bidi_2_AA: case Bidi_2_AB: case Bidi_2_AC: case Bidi_2_AD: case Bidi_2_AE:
|
||||
cur += 3;
|
||||
default:
|
||||
if ((b & 0xff) > 127) {// PATCH.JAVA:need to convert to unsigned byte
|
||||
Object char_obj = char_trie.Match_bgn_w_byte(b, src, cur, end);
|
||||
if (char_obj != null) {
|
||||
int tid = ((Int_obj_val)(char_obj)).Val();
|
||||
switch (tid) {
|
||||
case Char__bidi: // ignore bidi
|
||||
cur = char_trie.Match_pos();
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case Char__ws: // treat extended_ws as space; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
cur = char_trie.Match_pos();
|
||||
if (ltr_bgn != -1) add_ws = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++cur;
|
||||
if (add_ws) { // add ws and toggle flag
|
||||
@@ -362,17 +370,6 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
public static final int Wik_bgn_int = -1;
|
||||
public static final byte Subpage_spr = Byte_ascii.Slash; // EX: A/B/C
|
||||
public static final int Anch_bgn_anchor_only = 1; // signifies lnki which is only anchor; EX: [[#anchor]]
|
||||
private static final byte // NOTE: Bidi characters appear in File titles /\xE2\x80[\x8E\x8F\xAA-\xAE]/S
|
||||
Bidi_0_E2 = (byte)226
|
||||
, Bidi_1_80 = (byte)128
|
||||
, Bidi_2_8E = (byte)142
|
||||
, Bidi_2_8F = (byte)143
|
||||
, Bidi_2_AA = (byte)170
|
||||
, Bidi_2_AB = (byte)171
|
||||
, Bidi_2_AC = (byte)172
|
||||
, Bidi_2_AD = (byte)173
|
||||
, Bidi_2_AE = (byte)174
|
||||
;
|
||||
public static final int Max_len = 2048; // ASSUME: max len of 256 * 8 bytes
|
||||
public static final int Null_wik_bgn = -1;
|
||||
public static final Xoa_ttl Null = null;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.lists.*;
|
||||
class Xop_colon_lxr implements Xop_lxr {
|
||||
public class Xop_colon_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_colon;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Colon, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
@@ -79,7 +79,7 @@ public class Xop_ctx {
|
||||
return this;
|
||||
}
|
||||
public String Page_url_str() {
|
||||
try {return cur_page.Url().Xto_full_str_safe();}
|
||||
try {return cur_page.Url().To_str();}
|
||||
catch (Exception e) {Err_.Noop(e); return "page_url shouldn't fail";}
|
||||
}
|
||||
public void Page_bgn(Xop_root_tkn root, byte[] src) {
|
||||
|
||||
@@ -197,8 +197,9 @@ public class Xop_fxt {
|
||||
app.Usere().Wiki().Xwiki_mgr().Add_full(domain, domain);
|
||||
return this;
|
||||
}
|
||||
public Xop_fxt Init_xwiki_add_user_(String domain) {
|
||||
app.Usere().Wiki().Xwiki_mgr().Add_full(domain, domain);
|
||||
public Xop_fxt Init_xwiki_add_user_(String domain) {return Init_xwiki_add_user_(domain, domain);}
|
||||
public Xop_fxt Init_xwiki_add_user_(String alias, String domain) {
|
||||
app.Usere().Wiki().Xwiki_mgr().Add_full(alias, domain);
|
||||
return this;
|
||||
}
|
||||
public void Test_parse_template(String tmpl_raw, String expd) {Test_parse_tmpl_str_test(tmpl_raw, "{{test}}", expd);}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Xop_redirect_mgr {
|
||||
if (i != 0) redirect_bfr.Add(Bry_redirect_dlm);
|
||||
byte[] redirect_ttl = (byte[])list.Get_at(i);
|
||||
redirect_bfr.Add(Xoh_consts.A_bgn) // '<a href="'
|
||||
.Add(Xoh_href_parser.Href_wiki_bry) // '/wiki/'
|
||||
.Add(Xoh_href_.Bry__wiki) // '/wiki/'
|
||||
.Add(redirect_ttl) // 'PageA'
|
||||
.Add(Bry_redirect_arg) // ?redirect=no
|
||||
.Add(Xoh_consts.A_bgn_lnki_0) // '" title="'
|
||||
|
||||
@@ -26,8 +26,8 @@ public class Xop_redirect_mgr_tst {
|
||||
@Test public void Exc_false_match() {fxt.Test_redirect("#REDIRECTA [[a]]", "");}
|
||||
@Test public void Exc_lnki_not_found() {fxt.Test_redirect("#REDIRECT test", "");}
|
||||
@Test public void Ws() {fxt.Test_redirect("\n#REDIRECT [[a]]", "A");} // PAGE:en.w:Germany; {{Template group}} -> \n#REDIRECT [[Template:Navboxes]]
|
||||
@Test public void Utf8() {
|
||||
fxt.Init_utf8();
|
||||
@Test public void U8() {
|
||||
fxt.Init_u8();
|
||||
fxt.Init_kwds(Bool_.N, "#REDIRECT", "#перенаправление");
|
||||
fxt.Test_redirect("#REDIRECT [[A]]", "A");
|
||||
fxt.Test_redirect("#reDirect [[A]]", "A");
|
||||
@@ -47,8 +47,8 @@ class Xop_redirect_mgr_fxt {
|
||||
fxt.Reset();
|
||||
}
|
||||
public void Init_kwds(boolean case_match, String... kwds) {fxt.Init_lang_kwds(Xol_kwd_grp_.Id_redirect, case_match, kwds);}
|
||||
public void Init_utf8() {
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
public void Init_u8() {
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
}
|
||||
public void Test_frame_ttl(String tmpl_ttl_str, String tmpl_wtxt_str, String redirect_ttl, String expd_frame_ttl) {
|
||||
fxt.Init_page_create(tmpl_ttl_str, tmpl_wtxt_str); // create redirect_src
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.amps.*;
|
||||
public class Xop_sanitizer {
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.cs_(), amp_trie;
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.cs(), amp_trie;
|
||||
private Xop_amp_mgr amp_mgr;
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public Xop_sanitizer(Xop_amp_mgr amp_mgr, Gfo_msg_log msg_log) {
|
||||
@@ -76,7 +76,7 @@ public class Xop_sanitizer {
|
||||
switch (itm_tid) {
|
||||
case Xop_amp_trie_itm.Tid_name_std:
|
||||
case Xop_amp_trie_itm.Tid_name_xowa:
|
||||
bfr.Add(itm.Utf8_bry());
|
||||
bfr.Add(itm.U8_bry());
|
||||
pos += itm.Key_name_len() + 1; // 1 for trailing ";"; EX: for " ", (a) pos is at "&", (b) "nbsp" is Key_name_len, (c) ";" needs + 1
|
||||
break;
|
||||
case Xop_amp_trie_itm.Tid_num_dec:
|
||||
|
||||
@@ -35,7 +35,7 @@ class Xop_sanitizer_fxt {
|
||||
public Xop_sanitizer sanitizer;
|
||||
public void Clear() {
|
||||
if (sanitizer != null) return;
|
||||
sanitizer = new Xop_sanitizer(new Xop_amp_mgr(), new Gfo_msg_log(Xoa_app_.Name));
|
||||
sanitizer = new Xop_sanitizer(Xop_amp_mgr.I, new Gfo_msg_log(Xoa_app_.Name));
|
||||
}
|
||||
public void tst_Escape_id(String raw, String expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
|
||||
Reference in New Issue
Block a user