1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Xomw: Convert Sanitizer, StringUtils; also, support stripAllTags

This commit is contained in:
gnosygnu
2017-02-23 09:08:03 -05:00
parent 09dbfc894e
commit 31fcfaf1bd
13 changed files with 2082 additions and 238 deletions

View File

@@ -1244,7 +1244,7 @@ public class XomwParser implements XomwParserIface {
// $text = $this->replaceTransparentTags( $text );
mStripState.unstripGeneral(pbfr);
sanitizer.Normalize_char_references(pbfr);
sanitizer.normalizeCharReferences(pbfr);
// if ( MWTidy::isEnabled() ) {
// if ( $this->mOptions->getTidy() ) {
@@ -4605,20 +4605,11 @@ public class XomwParser implements XomwParserIface {
// that are later expanded to html- so expand them now and
// remove the tags
tooltip = this.mStripState.unstripBoth(tooltip);
// tooltip = Sanitizer::stripAllTags( tooltip );
tooltip = sanitizer.stripAllTags(tooltip);
return tooltip;
}
// protected function stripAltText($caption, $holders) {
// # make sure there are no placeholders in thumbnail attributes
// # that are later expanded to html- so expand them now and
// # remove the tags
// $tooltip = this.mStripState->unstripBoth($tooltip);
// $tooltip = Sanitizer::stripAllTags($tooltip);
//
// return $tooltip;
// }
//
// /**
// * Set a flag in the output Object indicating that the content is dynamic and
// * shouldn't be cached.

View File

@@ -200,7 +200,7 @@ public class Xomw_parser implements XomwParserIface {
// $text = $this->replaceTransparentTags( $text );
strip_state.unstripGeneral(pbfr);
sanitizer.Normalize_char_references(pbfr);
sanitizer.normalizeCharReferences(pbfr);
// if ( MWTidy::isEnabled() ) {
// if ( $this->mOptions->getTidy() ) {

View File

@@ -203,7 +203,7 @@ public class Xomw_lnke_wkr {// THREAD.UNSAFE: caching for repeated calls
// $text = $this->getConverterLanguage()->markNoConversion( $text );
byte[] url = Bry_.Mid(src, url_bgn, url_end);
url = sanitizer.Clean_url(url);
url = sanitizer.cleanUrl(url);
bfr.Add_mid(src, prv, lnke_bgn);
prv = cur;

View File

@@ -472,7 +472,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// * text-bottom
// Protect LanguageConverter markup when splitting into parts
byte[][] parts = Xomw_string_utils.Delimiter_explode(tmp_list, trv, options_at_link);
byte[][] parts = XomwStringUtils.delimiterExplode(tmp_list, trv, options_at_link);
// Give extensions a chance to select the file revision for us
// $options = [];

View File

@@ -252,7 +252,7 @@ public class Xomw_magiclinks_wkr {
return;
}
url = sanitizer.Clean_url(url);
url = sanitizer.cleanUrl(url);
// XO.MW.UNSUPPORTED.NON-WMF: not supporting images from freefrom url; (EX: "http://a.org/image.png" -> "<img>"); haven't seen this used on WMF wikis
// Is this an external image?

View File

@@ -107,7 +107,7 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
for (int j = 0; j < indent_level; j++)
tmp.Add(Html__dl__bgn);
tmp.Add_str_a7("<table");
sanitizer.Fix_tag_attributes(tmp, Name__table, tblw_atrs);
sanitizer.fixTagAttributes(tmp, Name__table, tblw_atrs);
tmp.Add_byte(Byte_ascii.Angle_end);
out_line = tmp.To_bry_and_clear();
td_history.Add(false);
@@ -150,7 +150,7 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
// Whats after the tag is now only attributes
byte[] atrs = strip_state.unstripBoth(line);
sanitizer.Fix_tag_attributes(tmp, Name__tr, atrs);
sanitizer.fixTagAttributes(tmp, Name__tr, atrs);
atrs = tmp.To_bry_and_clear();
Php_ary_.Pop_bry_or_null(tr_attributes);
@@ -188,7 +188,7 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
// Implies both are valid for table headings.
if (first_char == Byte_ascii.Bang) {
Xomw_string_utils.Replace_markup(line, 0, line.length, Wtxt__th2, Wtxt__td2); // $line = StringUtils::replaceMarkup('!!', '||', $line);
XomwStringUtils.replaceMarkup(line, 0, line.length, Wtxt__th2, Wtxt__td2); // $line = StringUtils::replaceMarkup('!!', '||', $line);
}
// Split up multiple cells on the same line.
@@ -253,7 +253,7 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
else {
byte[] atrs = strip_state.unstripBoth(cell_data_0);
tmp.Add(previous).Add_byte(Byte_ascii.Angle_bgn).Add(last_tag);
sanitizer.Fix_tag_attributes(tmp, last_tag, atrs);
sanitizer.fixTagAttributes(tmp, last_tag, atrs);
tmp.Add_byte(Byte_ascii.Angle_end).Add(cell_data_1);
cell = tmp.To_bry_and_clear();
}