Skip to content

Commit b238b4e

Browse files
author
Your Name
committed
fix: improve HTML content extraction logic and escape movie titles in image alt attributes.
1 parent bdff5f3 commit b238b4e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/domain/services/streaming_service.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,15 @@ fn parse_movie_article(content: &str) -> Option<Value> {
313313

314314
fn extract_simple_content(html: &str, class_marker: &str, end_tag: &str) -> Option<String> {
315315
if let Some(marker_pos) = html.find(class_marker) {
316-
let content_start = marker_pos + class_marker.len();
317-
// Skip > if we just searched for a class
318-
let start = if html[content_start..].starts_with(">") {
319-
content_start + 1
320-
} else {
321-
content_start
322-
};
316+
let after_marker = marker_pos + class_marker.len();
323317

324-
if let Some(end_pos) = html[start..].find(end_tag) {
325-
return Some(html[start..start + end_pos].trim().to_string());
318+
// Find the closing '>' of the current tag
319+
if let Some(tag_end) = html[after_marker..].find('>') {
320+
let start = after_marker + tag_end + 1;
321+
322+
if let Some(end_pos) = html[start..].find(end_tag) {
323+
return Some(html[start..start + end_pos].trim().to_string());
324+
}
326325
}
327326
}
328327
None

static/js/streaming.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ const StreamingManager = {
8080

8181
container.innerHTML = this.filteredMovies.map(movie => {
8282
const searchUrl = `https://thpibay.site/search/${encodeURIComponent(movie.title)}/1/99/0`;
83+
const escapedTitle = movie.title.replace(/"/g, '&quot;');
8384

8485
return `
8586
<div class="movie-card">
8687
<span class="badge badge-lang">${movie.language}</span>
8788
<span class="badge badge-quality">${movie.quality}</span>
8889
<img src="${movie.poster_url || '/static/images/no-poster.png'}"
8990
class="movie-poster"
90-
alt="${movie.title}"
91+
alt="${escapedTitle}"
9192
onerror="this.src='/static/images/no-poster.png'"
9293
onclick="window.open('${movie.url}', '_blank')">
9394
<div class="movie-info">

0 commit comments

Comments
 (0)