Module:PageSummary:修订间差异
武外梗百科 爱国好学自强图新的百科全书
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第64行: | 第64行: | ||
local rawExcerpt = mw.ustring.sub(content, 1, 800) or "" | local rawExcerpt = mw.ustring.sub(content, 1, 800) or "" | ||
-- | -- 强力提取第一张图片(只抓有效文件名) | ||
local firstImage = mw.ustring.match(rawExcerpt, "%[%[File:([^|]+)") | local firstImage = mw.ustring.match(rawExcerpt, "%[%[File:([^|%]]+)") | ||
or mw.ustring.match(rawExcerpt, "%[%[文件:([^|]+)") | or mw.ustring.match(rawExcerpt, "%[%[文件:([^|%]]+)") | ||
-- | -- 超级严格验证:必须是图片文件名(含 ":" 和 ".") | ||
if firstImage then | if firstImage then | ||
firstImage = mw.text.trim(firstImage) | firstImage = mw.text.trim(firstImage) | ||
firstImage = mw.ustring.gsub(firstImage, "[%z%s<>\"]+", "") | firstImage = mw.ustring.gsub(firstImage, "[%z%s<>\"]+", "") | ||
if mw.ustring. | if not mw.ustring.find(firstImage, ":") or not mw.ustring.find(firstImage, "%.") or mw.ustring.len(firstImage) < 6 then | ||
firstImage = nil | firstImage = nil | ||
end | end | ||
| 第111行: | 第111行: | ||
:css('font-size', '14px') | :css('font-size', '14px') | ||
-- | -- 只有图片真正有效时才输出,彻底杜绝泄漏 | ||
if firstImage and firstImage ~= "" then | if firstImage and firstImage ~= "" then | ||
textDiv:wikitext('[[' .. firstImage .. '|120px|right|link=' .. pageName .. ']]') | textDiv:wikitext('[[' .. firstImage .. '|120px|right|link=' .. pageName .. ']]') | ||