diff --git a/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_mgr.java b/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_mgr.java index b57658150..29382851f 100644 --- a/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_mgr.java +++ b/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_mgr.java @@ -33,6 +33,7 @@ import gplx.core.threads.*; import gplx.core.net.*; import gplx.core.primitives. import gplx.langs.jsons.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.addons.wikis.searchs.gui.htmlbars.*; +import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.errors.*; public class Http_server_mgr implements Gfo_invk { private final Object thread_lock = new Object(); private final Gfo_usr_dlg usr_dlg; @@ -116,7 +117,13 @@ public class Http_server_mgr implements Gfo_invk { } finally {tmp_bfr.Mkr_rls();} } Xoa_url url = wiki.Utl__url_parser().Parse(ttl_bry); - Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.To_bry_page_w_anch()); // changed from ttl_bry to page_w_anch; DATE:2017-07-24 + Xoa_ttl ttl = wiki.Ttl_parse(url.To_bry_page_w_anch()); // changed from ttl_bry to page_w_anch; DATE:2017-07-24 + + // handle invalid titles like "Earth]"; ISSUE#:480; DATE:2019-06-02 + if (ttl == null) { + ttl = wiki.Ttl_parse(Xow_special_meta_.Itm__error.Ttl_bry()); + url = wiki.Utl__url_parser().Parse(Xoerror_special.Make_url__invalidTitle(ttl_bry)); + } // get the page gplx.xowa.guis.views.Xog_tab_itm tab = Gxw_html_server.Assert_tab2(app, wiki); // HACK: assert tab exists diff --git a/400_xowa/src/gplx/xowa/specials/Xow_special_meta_.java b/400_xowa/src/gplx/xowa/specials/Xow_special_meta_.java index 5821cd85b..d9de28d76 100644 --- a/400_xowa/src/gplx/xowa/specials/Xow_special_meta_.java +++ b/400_xowa/src/gplx/xowa/specials/Xow_special_meta_.java @@ -32,6 +32,7 @@ public class Xow_special_meta_ { , Ttl__page_history = "XowaHistory" , Ttl__bookmarks = "XowaBookmarks" , Ttl__diag = "XowaDiag" + , Ttl__error = "XowaError" ; public static final Xow_special_meta Itm__all_pages = new Xow_special_meta(Src__mw , Ttl__all_pages) @@ -49,5 +50,6 @@ public class Xow_special_meta_ { , Itm__page_history = new Xow_special_meta(Src__xowa , Ttl__page_history) , Itm__bookmarks = new Xow_special_meta(Src__xowa , Ttl__bookmarks) , Itm__diag = new Xow_special_meta(Src__xowa , Ttl__diag) + , Itm__error = new Xow_special_meta(Src__xowa , Ttl__error) ; } diff --git a/400_xowa/src/gplx/xowa/specials/Xow_special_mgr.java b/400_xowa/src/gplx/xowa/specials/Xow_special_mgr.java index ff64394b5..8e8be88b8 100644 --- a/400_xowa/src/gplx/xowa/specials/Xow_special_mgr.java +++ b/400_xowa/src/gplx/xowa/specials/Xow_special_mgr.java @@ -18,7 +18,7 @@ import gplx.xowa.users.history.*; import gplx.xowa.langs.*; import gplx.xowa.langs.specials.*; import gplx.xowa.specials.*; import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.nearby.*; import gplx.xowa.specials.statistics.*; import gplx.xowa.xtns.translates.*; import gplx.xowa.specials.movePage.*; -import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.addons.wikis.imports.*; import gplx.xowa.specials.xowa.diags.*; import gplx.xowa.xtns.wbases.mediawiki.repo.includes.specials.*; +import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.addons.wikis.imports.*; import gplx.xowa.specials.xowa.diags.*; import gplx.xowa.xtns.wbases.mediawiki.repo.includes.specials.*; import gplx.xowa.specials.xowa.errors.*; import gplx.xowa.xtns.wbases.specials.*; import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*; import gplx.xowa.specials.mgrs.*; import gplx.xowa.addons.wikis.searchs.specials.*; @@ -47,6 +47,7 @@ public class Xow_special_mgr { public Popup_history_page Page_popup_history() {return page_popup_history;} private final Popup_history_page page_popup_history = new Popup_history_page(); public Xows_bmk_page Page_bmk() {return page_bmk;} private final Xows_bmk_page page_bmk = new Xows_bmk_page(); public Xows_diag_page Page_diag() {return page_diag;} private final Xows_diag_page page_diag = new Xows_diag_page(); + public Xoerror_special Page_error() {return page_error;} private final Xoerror_special page_error = new Xoerror_special(); public void Evt_lang_changed(Xol_lang_itm lang) { // add special pages by old manual method; DEPRECATED hash.Clear(); @@ -66,6 +67,7 @@ public class Xow_special_mgr { hash.Add_str_obj(Xow_special_meta_.Ttl__popup_history , page_popup_history); hash.Add_str_obj(Xow_special_meta_.Ttl__bookmarks , page_bmk); hash.Add_str_obj(Xow_special_meta_.Ttl__diag , page_diag); + hash.Add_str_obj(Xow_special_meta_.Ttl__error , page_error); // add app's Special_regy to hash table; needed for case insensitivity by wiki's lang; EX: Special:rANDom; NOTE: needs to go before lang aliases Xoa_special_regy special_regy = app.Special_regy(); diff --git a/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java b/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java new file mode 100644 index 000000000..6b004e915 --- /dev/null +++ b/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java @@ -0,0 +1,47 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012-2017 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. + +You may use XOWA according to either of these licenses as is most appropriate +for your project on a case-by-case basis. + +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.specials.xowa.errors; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*; +import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.net.*; import gplx.core.net.qargs.*; +import gplx.xowa.langs.*; +import gplx.xowa.apps.urls.*; +public class Xoerror_special implements Xow_special_page { + public Xow_special_meta Special__meta() {return Xow_special_meta_.Itm__error;} + public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) { + Xoae_page page = (Xoae_page)pagei; + Gfo_qarg_mgr qarg_mgr = new Gfo_qarg_mgr(); + qarg_mgr.Init(url.Qargs_ary()); + String type = qarg_mgr.Read_str_or("type", "unknown type"); + String data = qarg_mgr.Read_str_or("data", "unknown data"); + String title = type; + String msg = data; + if (String_.Eq(type, "InvalidTitle")) { + title = "Invalid title"; + msg = "The title has invalid characters: " + data + ""; + } + + page.Db().Text().Text_bry_(fmt.Bld_many_to_bry(Bry_bfr_.New(), title, msg)); + } + private static final Bry_fmt fmt = Bry_fmt.Auto(String_.Concat_lines_nl_skip_last + ( "
~{msg}" + , "
" + )); + + public Xow_special_page Special__clone() {return this;} + public static byte[] Make_url__invalidTitle(byte[] invalid_title) { + return Bry_.Add(Xow_special_meta_.Itm__error.Ttl_bry(), Bry_.new_a7("?type=InvalidTitle&data="), invalid_title); + } +}