Skip to content

Commit

Permalink
fix /<\!/
Browse files Browse the repository at this point in the history
  • Loading branch information
kanasimi committed Dec 2, 2024
1 parent 1de65b5 commit 0ce9f80
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 95 deletions.
8 changes: 4 additions & 4 deletions application/locale/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,20 +915,20 @@ function module_code(library_namespace) {
library_namespace.debug('<em>2.</em> '
+ text.length
+ ' characters: ['
+ text.replace(/<!--[\s\S]*?-->/g, '').replace(/</g,
+ text.replace(/<\!--[\s\S]*?-->/g, '').replace(/</g,
'&lt;') + ']');
library_namespace.debug('<em>3.</em> '
+ text.length
+ ' characters: ['
+ text.replace(/<!--[\s\S]*?-->/g, '').replace(
+ text.replace(/<\!--[\s\S]*?-->/g, '').replace(
/<script([\s\n][^>]*)?>[\s\S]*?<\/script>/ig,
'').replace(/</g, '&lt;') + ']');
}

// 去掉 markup (<> 標籤),僅留 contents。
text = text
// 去掉 comments.
.replace(/<!--[\s\S]*?-->/g, '').replace(
// 去除註解。 Remove comments. "<!-- comment -->"
.replace(/<\!--[\s\S]*?-->/g, '').replace(
/<script([\s\n][^>]*)?>[\s\S]*?<\/script>/ig, '').replace(
/[\s\n]*<[\w?!\/][^>]*>/g, '')
// 把最後未完結的 tag 刪掉。
Expand Down
80 changes: 40 additions & 40 deletions application/locale/resources/i18n/qqq.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion application/locale/resources/i18n/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"españa": "西班牙",
"french-republican-calendar": "法国共和历",
"untranslated-message-count": "100+",
"untranslated-message-count": "0",
"clear-log": "清除信息",
"show-hidden-log": "显示/隐藏日志",
"load-failed": "加载失败",
Expand Down
72 changes: 36 additions & 36 deletions application/locale/resources/qqq_data.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions application/net/wiki/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@ function module_code(library_namespace) {
// assert: !content || typeof content === 'string'

if (typeof content === 'string') {
content = content.replace(/<!--[\s\S]*?-->/g, '').replace(
// 去掉絕對不會影響 deny code 的內容。
content = content.replace(/<\!--[\s\S]*?-->/g, '').replace(
/<nowiki\s*>[\s\S]*<\/nowiki>/g, '');
}
if (!content)
Expand Down Expand Up @@ -1855,7 +1856,7 @@ function module_code(library_namespace) {
}

Variable_Map.plain_text = function plain_text(wikitext) {
return wiki_link.replace(/<!--[\s\S]*?-->/g, '');
return wiki_link.replace(/<\!--[\s\S]*?-->/g, '');
};

wiki_API.Variable_Map = Variable_Map;
Expand Down
2 changes: 1 addition & 1 deletion application/net/wiki/featured_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function module_code(library_namespace) {

if (matched[3]) {
// 分類/類別。
catalog = matched[3].replace(/<!--[\s\S]*?-->/g, '').trim()
catalog = matched[3].replace(/<\!--[\s\S]*?-->/g, '').trim()
.replace(/\s*\d+$/, '');
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion application/net/wiki/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ function module_code(library_namespace) {
// 罕見情況下,有可能 data === undefined
data = data.text['*']
// 去掉 MediaWiki parser 解析器所自行添加的 token 與註解。
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/<\!--[\s\S]*?-->/g, '')
// 去掉前後包覆。 e.g., <p> or <pre>
.replace(/![^!]*$/, '').replace(/^[^!]*!/, '');

Expand Down
6 changes: 3 additions & 3 deletions application/net/wiki/parser/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function module_code(library_namespace) {
// 採用比較寬鬆的標準。
return !(token.type in {
parameter : true,
// e.g., {{=}}
// e.g., {{!}} {{=}}
magic_word_function : true,
transclusion : true,
comment : true
Expand Down Expand Up @@ -1731,8 +1731,8 @@ function module_code(library_namespace) {
// wikilink → page title
.replace(/^\[\[ *:?([^{}\[\]\|<>\t\n]+)(?:\|[^\[\]{}]+?)?\]\]$/,
'$1')
// Remove comments
.replace(/<!--[\s\S]*?-->/g, '');
// 去除註解。 Remove comments. "<!-- comment -->"
.replace(/<\!--[\s\S]*?-->/g, '');

// console.trace([ JS_value, wiki_API.parse(JS_value), value ]);

Expand Down
2 changes: 1 addition & 1 deletion application/net/work_crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ function module_code(library_namespace) {
// node.innerText
function get_label(html) {
return html ? library_namespace.HTML_to_Unicode(
html.replace(/<!--[\s\S]*?-->/g, '').replace(
html.replace(/<\!--[\s\S]*?-->/g, '').replace(
/<(script|style)[^<>]*>[\s\S]*?<\/\1>/g, '').replace(
/\s*<br(?:[^\w<>][^<>]*)?>[\r\n]*/ig, '\n').replace(
/<\/?[a-z][^<>]*>/g, '')
Expand Down
2 changes: 1 addition & 1 deletion application/net/work_crawler/sites/dm5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ function module_code(library_namespace) {
*/
|| html.between(' id="cp_img">', '</div>')
//
.replace(/<!--[\s\S]*?-->/g, '');
.replace(/<\!--[\s\S]*?-->/g, '');

// console.log(html);

Expand Down
2 changes: 1 addition & 1 deletion application/storage/EPUB.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ function module_code(library_namespace) {

resources.forEach(function(resource, index) {
if (typeof resource === 'string') {
var matched = resource.match(/<!--\s*({.+})\s*-->/);
var matched = resource.match(/<\!--\s*({.+?})\s*-->/);
if (matched
//
&& library_namespace.is_Object(resources[--index])) {
Expand Down
2 changes: 1 addition & 1 deletion data.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ function module_code(library_namespace) {
// 和perl不同,JScript常抓不到(.*?)之後還接特定字串的東西,大概因為沒有s。(.*?)得改作([\s\S]*?)?
// 或者該加/img?
if (is_HTML)
text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(
text = text.replace(/<\!--[\s\S]*?-->/g, '').replace(
/<[\s\n]*\/?[\s\n]*[a-z][^<>]*>/gi, '');

if (flag & 2)
Expand Down
2 changes: 1 addition & 1 deletion data/Convert_Pairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function module_code(library_namespace) {
// // ...
.replace(/\/\/[^\r\n]*/g, '');

// text.replace(/<!--[\s\S]*?-->/g, '');
// text.replace(/<\!--[\s\S]*?-->/g, '');

// TODO: /^#/
}
Expand Down
4 changes: 2 additions & 2 deletions interact/DOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -8652,9 +8652,9 @@ _
}) ? $0 : '';
};
if (false) {
if (m = t.match(/<!--\[if [^\]]+\]>[\s\S]*?<!\[endif\]-->/))
if (m = t.match(/<\!--\[if [^\]]+\]>[\s\S]*?<!\[endif\]-->/))
sl(m[0].replace(/</g, '&lt;'));
if (m = t.match(/<!\[if !vml\]>[\s\S]*?<!\[endif\]>/))
if (m = t.match(/<\!\[if !vml\]>[\s\S]*?<!\[endif\]>/))
sl(m[0]);
}

Expand Down

0 comments on commit 0ce9f80

Please sign in to comment.