Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpg/webp/png may appear at alt attribute cause a mistake #689

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ Readability.prototype = {

for (var j = 0; j < elem.attributes.length; j++) {
attr = elem.attributes[j];
if (attr.name === "src" || attr.name === "srcset") {
if (attr.name === "src" || attr.name === "srcset" || attr.name === "alt") {
continue;
}
var copyTo = null;
Expand Down
7 changes: 7 additions & 0 deletions test/test-pages/lazy-image-3/expected-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Lazy Load with Alt includes jpg/png/webp extensions",
"byline": null,
"dir": null,
"siteName": null,
"readerable": false
}
8 changes: 8 additions & 0 deletions test/test-pages/lazy-image-3/expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="readability-page-1" class="page">
<article>
<h2>Test Case 1</h2>
<img data-src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.jpg" alt="performance.jpg" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.jpg" />
<h2>Test Case 2</h2>
<img data-src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.png" alt="performance.jpg" src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.png" />
</article>
</div>
21 changes: 21 additions & 0 deletions test/test-pages/lazy-image-3/source.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Lazy Load with Alt includes jpg/png/webp extensions</title>
</head>
<body>
<article class="markdown-body">
<h2>Test Case 1</h2>
<img class="lazyload inited loaded"
data-src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.jpg"
alt="performance.jpg"
/>
<h2>Test Case 2</h2>
<img class="lazyload inited loaded"
data-src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0579d17015b145a88dd93992c6447d7d~tplv-k3u1fbpfcp-watermark.png"
alt="performance.jpg"
/>
</article>
</body>
</html>