From e6283cefeb81a5fecaedee89b944a0880c5e6aaa Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 14 Jan 2026 14:29:12 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20R=C3=A9parer=20le=20workflow=20d'agr?= =?UTF-8?q?=C3=A9gation=20automatique=20des=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problèmes résolus : - ✅ Correction fonction sanitizeArticle : suppression appels addUTMParams() et cleanSummary() inexistants - ✅ Utilisation de getArticleLink() pour liens directs sans UTM tracking - ✅ Suppression code dupliqué htmlEscape() - ✅ Correction package.json : déplacement sanitize-html vers dependencies - ✅ Mise en commentaire LinkedIn dans le workflow (temporairement désactivé) Le workflow devrait maintenant s'exécuter toutes les 6h sans erreur. --- .github/workflows/update-ai-pulse.yml | 7 ++++--- package-lock.json | 9 ++++++++- package.json | 5 ++--- src/aggregator.js | 26 ++------------------------ 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.github/workflows/update-ai-pulse.yml b/.github/workflows/update-ai-pulse.yml index b6f5b600a..852b9267b 100644 --- a/.github/workflows/update-ai-pulse.yml +++ b/.github/workflows/update-ai-pulse.yml @@ -29,9 +29,10 @@ jobs: npm install axios cheerio rss-parser @octokit/rest - name: Aggregate AI and Cybersecurity articles - env: - LINKEDIN_ACCESS_TOKEN: ${{ secrets.LINKEDIN_ACCESS_TOKEN }} - LINKEDIN_USER_ID: ${{ secrets.LINKEDIN_USER_ID }} + # LinkedIn integration temporarily disabled + # env: + # LINKEDIN_ACCESS_TOKEN: ${{ secrets.LINKEDIN_ACCESS_TOKEN }} + # LINKEDIN_USER_ID: ${{ secrets.LINKEDIN_USER_ID }} run: | node src/aggregator.js | tee NEW-README.md diff --git a/package-lock.json b/package-lock.json index 900578b21..6c6c0baae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,13 @@ { - "name": "AI-Pulse", + "name": "ai-pulse", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "ai-pulse", + "version": "1.0.0", + "license": "MIT", "dependencies": { "@octokit/rest": "^22.0.1", "axios": "^1.13.2", @@ -14,6 +18,9 @@ "isomorphic-dompurify": "^2.35.0", "rss-parser": "^3.13.0", "sanitize-html": "^2.17.0" + }, + "engines": { + "node": ">=20.0.0" } }, "node_modules/@acemir/cssom": { diff --git a/package.json b/package.json index f87341ede..8b650bb10 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,10 @@ "dompurify": "^3.3.1", "express": "^5.2.1", "isomorphic-dompurify": "^2.35.0", - "rss-parser": "^3.13.0" + "rss-parser": "^3.13.0", + "sanitize-html": "^2.17.0" }, "engines": { "node": ">=20.0.0" - "rss-parser": "^3.13.0", - "sanitize-html": "^2.17.0" } } diff --git a/src/aggregator.js b/src/aggregator.js index dbaca40fc..5e182cc9e 100644 --- a/src/aggregator.js +++ b/src/aggregator.js @@ -91,40 +91,18 @@ function smartTruncate(text, maxLength = 500) { return truncated.trim() + '...'; } -/** - * HTML-escape a string so it is safe to insert into HTML contexts. - * Converts &, <, and > to their corresponding entities. - * @param {string} input - * @returns {string} - */ -function htmlEscape(input) { - if (!input) { - return ''; - } - return input - .replace(/&/g, '&') - .replace(//g, '>'); -} - // Sanitize and process articles function sanitizeArticle(article, sourceName, tags, category) { - const rawSummary = htmlEscape( - article.contentSnippet?.replace(/<[^>]*>/g, '') || '' - ); - - return { - title: htmlEscape(article.title?.replace(/<[^>]*>/g, '') || '').slice(0, 200) || 'Untitled', const rawSummary = sanitizeText(article.contentSnippet) || ''; return { title: (sanitizeText(article.title) || 'Untitled').slice(0, 200), - link: addUTMParams(article.link, category), // UTM tracks traffic FROM AI-Pulse + link: getArticleLink(article.link, category), // Direct link without UTM tracking pubDate: new Date(article.pubDate || Date.now()), source: sourceName, tags: tags, category: article.categories?.[0] || 'General', - summary: smartTruncate(htmlEscape(cleanSummary), 600) // DOMPurify removes tags, htmlEscape handles entities + summary: smartTruncate(rawSummary, 600) }; }