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:
@@ -29,7 +29,7 @@ public class Xoae_page implements Xoa_page {
|
||||
} Xoae_page() {} // called by Null
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xoa_ttl Ttl() {return ttl;} public Xoae_page Ttl_(Xoa_ttl v) {ttl = v; url.Wiki_bry_(wiki.Domain_bry()).Page_bry_(v.Full_url()); return this;} private Xoa_ttl ttl;
|
||||
public Xoa_url Url() {return url;} public Xoae_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank_();
|
||||
public Xoa_url Url() {return url;} public Xoae_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank();
|
||||
public byte[] Url_bry_safe() {return url == null ? Bry_.Empty : url.Raw();}
|
||||
public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();}
|
||||
public boolean Exists() {return !Missing();}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.net.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.core.net.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.html.hrefs.*;
|
||||
public class Xop_link_parser {
|
||||
public byte[] Html_xowa_ttl() {return html_xowa_ttl;} private byte[] html_xowa_ttl;
|
||||
@@ -25,26 +25,30 @@ public class Xop_link_parser {
|
||||
public byte[] Parse(Bry_bfr tmp_bfr, Xoa_url tmp_url, Xowe_wiki wiki, byte[] raw, byte[] or) {
|
||||
html_xowa_ttl = null; html_anchor_cls = Xoh_lnki_consts.Tid_a_cls_image; html_anchor_rel = Xoh_lnki_consts.Tid_a_rel_none; // default member variables for html
|
||||
Xoae_app app = wiki.Appe(); int raw_len = raw.length;
|
||||
app.Utl__url_parser().Parse(tmp_url, raw);
|
||||
wiki.Utl__url_parser().Parse(tmp_url, raw);
|
||||
switch (tmp_url.Protocol_tid()) {
|
||||
case Xoo_protocol_itm.Tid_http: case Xoo_protocol_itm.Tid_https: // "http:" or "https:"; check if to offline wiki and redirect
|
||||
case Gfo_protocol_itm.Tid_http: case Gfo_protocol_itm.Tid_https: // "http:" or "https:"; check if to offline wiki and redirect
|
||||
byte[] wiki_bry = tmp_url.Wiki_bry(), page_bry = tmp_url.Page_bry();
|
||||
if (Bry_.Eq(wiki_bry, wiki.Domain_bry()) // link is to this wiki; check if alias
|
||||
|| app.Xwiki_mgr__exists(wiki_bry)) { // link is to an xwiki
|
||||
if ( !tmp_url.Wiki_is_missing() // https://www.a.org and others will be marked "missing" by Xoa_url_parser
|
||||
&&( Bry_.Eq(wiki_bry, wiki.Domain_bry()) // link is to this wiki; check if alias
|
||||
|| app.Xwiki_mgr__exists(wiki_bry) // link is to an xwiki
|
||||
)
|
||||
) {
|
||||
page_bry = tmp_url.Page_for_lnki();
|
||||
Parse__ttl(tmp_bfr, wiki, wiki_bry, page_bry);
|
||||
}
|
||||
else { // http is to an unknown site
|
||||
if (tmp_url.Protocol_is_relative()) // relative protocol; EX:"//www.a.org";
|
||||
tmp_bfr.Add(tmp_url.Protocol_bry()).Add(raw); // prepend protocol b/c mozilla cannot launch "//www.a.org", but can launch "http://www.a.org"
|
||||
else // regular url
|
||||
tmp_bfr.Add(raw); // dump everything
|
||||
if (tmp_url.Protocol_is_relative()) { // relative protocol; EX:"//www.a.org";
|
||||
Gfo_protocol_itm protocol_itm = Gfo_protocol_itm.Get_or(wiki.Props().Protocol_tid(), Gfo_protocol_itm.Itm_https);
|
||||
tmp_bfr.Add(protocol_itm.Key_w_colon_bry()); // prepend protocol b/c mozilla cannot launch "//www.a.org", but can launch "https://www.a.org"; DATE:2015-07-27
|
||||
}
|
||||
tmp_bfr.Add(raw); // dump everything
|
||||
}
|
||||
raw = tmp_bfr.Xto_bry_and_clear();
|
||||
html_anchor_cls = Xoh_lnki_consts.Tid_a_cls_none;
|
||||
html_anchor_rel = Xoh_lnki_consts.Tid_a_rel_nofollow;
|
||||
break;
|
||||
case Xoo_protocol_itm.Tid_file: // "file:///" or "File:A.png"
|
||||
case Gfo_protocol_itm.Tid_file: // "file:///" or "File:A.png"
|
||||
int proto_len = tmp_url.Protocol_bry().length;
|
||||
if (proto_len + 1 < raw_len && raw[proto_len + 1] == Byte_ascii.Slash) { // next char is slash, assume xfer_itm refers to protocol; EX: file:///C/A.png
|
||||
int slash_pos = Bry_finder.Find_bwd(raw, Byte_ascii.Slash);
|
||||
@@ -52,7 +56,7 @@ public class Xop_link_parser {
|
||||
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Int_.Const_dlm_len, raw.length);
|
||||
}
|
||||
else // next char is not slash; assume xfer_itm refers to ns; EX:File:A.png
|
||||
raw = tmp_bfr.Add(Xoh_href_parser.Href_wiki_bry).Add(raw).Xto_bry_and_clear();
|
||||
raw = tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(raw).Xto_bry_and_clear();
|
||||
break;
|
||||
default: // is page only; EX: Abc
|
||||
if (Bry_.Len_eq_0(raw)) // NOTE: handle blank link; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]
|
||||
@@ -82,9 +86,9 @@ public class Xop_link_parser {
|
||||
page_bry = page_ttl.Full_db();
|
||||
}
|
||||
if (Bry_.Eq(wiki_bry, wiki.Domain_bry())) // NOTE: check against wiki.Key_bry() again; EX: in en_wiki, and http://commons.wikimedia.org/wiki/w:A
|
||||
tmp_bfr.Add(Xoh_href_parser.Href_wiki_bry).Add(page_bry);
|
||||
tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(page_bry);
|
||||
else
|
||||
tmp_bfr.Add(Xoh_href_parser.Href_site_bry).Add(wiki_bry).Add(Xoh_href_parser.Href_wiki_bry).Add(page_bry);
|
||||
tmp_bfr.Add(Xoh_href_.Bry__site).Add(wiki_bry).Add(Xoh_href_.Bry__wiki).Add(page_bry);
|
||||
return page_ttl_is_valid;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user