mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.4.1'
This commit is contained in:
@@ -162,18 +162,19 @@ public class Gfh_utl {
|
||||
public static byte[] Del_comments(Bry_bfr bfr, byte[] src, int pos, int end) {
|
||||
while (true) {
|
||||
if (pos >= end) break;
|
||||
int comm_bgn = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_bgn, pos); // look for <!--
|
||||
if (comm_bgn == Bry_find_.Not_found) { // not found; consume rest
|
||||
bfr.Add_mid(src, pos, end);
|
||||
break;
|
||||
int comm_bgn = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_bgn, pos); // look for <!--
|
||||
if (comm_bgn == Bry_find_.Not_found) { // <!-- not found;
|
||||
bfr.Add_mid(src, pos, end); // add everything between pos and <!--
|
||||
break; // stop checking
|
||||
}
|
||||
int comm_end = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_end, comm_bgn + Gfh_tag_.Comm_bgn_len); // look for -->
|
||||
if (comm_end == Bry_find_.Not_found) { // not found; consume rest
|
||||
bfr.Add_mid(src, pos, end);
|
||||
break;
|
||||
int comm_bgn_rhs = comm_bgn + Gfh_tag_.Comm_bgn_len;
|
||||
int comm_end = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_end, comm_bgn_rhs); // look for -->
|
||||
if (comm_end == Bry_find_.Not_found) { // --> not found
|
||||
bfr.Add_mid(src, pos, comm_bgn); // add everything between pos and comm_bgn; EX: "a<!--b->" must add "a"
|
||||
break; // stop checking
|
||||
}
|
||||
bfr.Add_mid(src, pos, comm_bgn); // add everything between pos and comm_bgn
|
||||
pos = comm_end + Gfh_tag_.Comm_end_len; // reposition pos after comm_end
|
||||
bfr.Add_mid(src, pos, comm_bgn); // add everything between pos and comm_bgn
|
||||
pos = comm_end + Gfh_tag_.Comm_end_len; // reposition pos after comm_end
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
|
||||
@@ -17,12 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*;
|
||||
public class Gfh_utl_tst {
|
||||
public class Gfh_utl__basic__tst {
|
||||
@Before public void init() {fxt.Clear();} private Gfh_class_fxt fxt = new Gfh_class_fxt();
|
||||
@Test public void Basic() {fxt.Test_del_comments("a<!-- b -->c" , "ac");}
|
||||
@Test public void Bgn_missing() {fxt.Test_del_comments("a b c" , "a b c");}
|
||||
@Test public void End_missing() {fxt.Test_del_comments("a<!-- b c" , "a<!-- b c");}
|
||||
@Test public void Multiple() {fxt.Test_del_comments("a<!--b-->c<!--d-->e" , "ace");}
|
||||
@Test public void Escape() {
|
||||
fxt.Test_escape_html(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, "a<b" , "a<b"); // basic
|
||||
fxt.Test_escape_html(Bool_.Y, Bool_.Y, Bool_.N, Bool_.Y, Bool_.Y, "a<&b" , "a<&b"); // fix: & not escaped when <> present
|
||||
26
400_xowa/src/gplx/langs/htmls/Gfh_utl__comments__tst.java
Normal file
26
400_xowa/src/gplx/langs/htmls/Gfh_utl__comments__tst.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*;
|
||||
public class Gfh_utl__comments__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Gfh_class_fxt fxt = new Gfh_class_fxt();
|
||||
@Test public void Basic() {fxt.Test_del_comments("a<!-- b -->c" , "ac");}
|
||||
@Test public void Bgn_missing() {fxt.Test_del_comments("a b c" , "a b c");}
|
||||
@Test public void End_missing() {fxt.Test_del_comments("a<!-- b c" , "a");}
|
||||
@Test public void Multiple() {fxt.Test_del_comments("a<!--b-->c<!--d-->e" , "ace");}
|
||||
}
|
||||
Reference in New Issue
Block a user