mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-09-28 22:40:50 +00:00
Parser.Lnke: Escape ampersand in external links [#371]
This commit is contained in:
parent
a70131254f
commit
beab14117e
@ -51,21 +51,19 @@ public class Xoh_lnke_html {
|
|||||||
|| hctx.Mode_is_hdump() // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
|| hctx.Mode_is_hdump() // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
||||||
|| hctx.Mode_is_file_dump()
|
|| hctx.Mode_is_file_dump()
|
||||||
) {
|
) {
|
||||||
if (lnke.Lnke_relative()) { // relative; EX: //a.org
|
// xowa; EX: "xowa:some_cmd"
|
||||||
bfr.Add(ctx.Wiki().Utl__url_parser().Url_parser().Relative_url_protocol_bry()).Add_mid(src, href_bgn, href_end);
|
if (proto_is_xowa) {
|
||||||
return true;
|
bfr.Add(Xop_lnke_wkr.Bry_xowa_protocol);
|
||||||
|
gfs_encoder.Encode(bfr, src, href_bgn, href_end);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else { // xowa or regular; EX: http://a.org
|
|
||||||
if (proto_is_xowa) {
|
// either relative (EX: "//a.org") or regular (EX: "http://a.org")
|
||||||
bfr.Add(Xop_lnke_wkr.Bry_xowa_protocol);
|
if (lnke.Lnke_relative()) {
|
||||||
gfs_encoder.Encode(bfr, src, href_bgn, href_end);
|
bfr.Add(ctx.Wiki().Utl__url_parser().Url_parser().Relative_url_protocol_bry());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else { // regular; add href
|
|
||||||
bfr.Add_mid(src, href_bgn, href_end);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Xoh_html_wtr_escaper.Escape(ctx.App().Parser_amp_mgr(), bfr, src, href_bgn, href_end, true, false); // escape & ISSUE#:371; DATE:2019-03-03
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else { // xwiki
|
else { // xwiki
|
||||||
byte[] xwiki_page_enc = href_encoder.Encode(lnke.Lnke_xwiki_page());
|
byte[] xwiki_page_enc = href_encoder.Encode(lnke.Lnke_xwiki_page());
|
||||||
|
@ -41,4 +41,11 @@ public class Xoh_lnke_html__basic__tst {
|
|||||||
fxt.Test__parse__wtxt_to_html(wtxt, html_https); // https b/c hdump, even though wiki installed
|
fxt.Test__parse__wtxt_to_html(wtxt, html_https); // https b/c hdump, even though wiki installed
|
||||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
||||||
}
|
}
|
||||||
|
@Test public void Ampersand() {
|
||||||
|
// relative
|
||||||
|
fxt.Test_parse_page_wiki_str("[//a.org/b?c1=d1&c2=d2 e]", "<a href=\"https://a.org/b?c1=d1&c2=d2\" rel=\"nofollow\" class=\"external text\">e</a>");
|
||||||
|
|
||||||
|
// regular
|
||||||
|
fxt.Test_parse_page_wiki_str("[https://a.org/b?c1=d1&c2=d2 e]" , "<a href=\"https://a.org/b?c1=d1&c2=d2\" rel=\"nofollow\" class=\"external text\">e</a>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class Xop_lnke_wkr_xwiki_tst {
|
|||||||
}
|
}
|
||||||
@Test public void Xwiki__history() { // PURPOSE: handle xwiki lnke's to history page else null ref; EX:[http://ru.wikipedia.org/w/index.php?title&diff=19103464&oldid=18910980 извещен]; PAGE:ru.w:Project:Заявки_на_снятие_флагов/Архив/Патрулирующие/2009 DATE:2016-11-24
|
@Test public void Xwiki__history() { // PURPOSE: handle xwiki lnke's to history page else null ref; EX:[http://ru.wikipedia.org/w/index.php?title&diff=19103464&oldid=18910980 извещен]; PAGE:ru.w:Project:Заявки_на_снятие_флагов/Архив/Патрулирующие/2009 DATE:2016-11-24
|
||||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
|
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
|
||||||
fxt.Test__parse__wtxt_to_html("[http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2 abc]", "<a href='http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2' rel='nofollow' class='external text'>abc</a>");
|
fxt.Test__parse__wtxt_to_html("[http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2 abc]", "<a href='http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2' rel='nofollow' class='external text'>abc</a>");
|
||||||
}
|
}
|
||||||
@Test public void Ignore_proto() { // PURPOSE: handle other protocols; PAGE:uk.w:Маскалі; DATE:2015-07-28
|
@Test public void Ignore_proto() { // PURPOSE: handle other protocols; PAGE:uk.w:Маскалі; DATE:2015-07-28
|
||||||
fxt.Test__parse__wtxt_to_html("[mailto:a b]", "<a href='mailto:a' rel='nofollow' class='external text'>b</a>");// should be /w/, not /en.wikipedia.org
|
fxt.Test__parse__wtxt_to_html("[mailto:a b]", "<a href='mailto:a' rel='nofollow' class='external text'>b</a>");// should be /w/, not /en.wikipedia.org
|
||||||
|
Loading…
Reference in New Issue
Block a user