scan_lobster_commit_encoding.mjs 977 B

1234567891011121314151617181920212223242526
  1. import { readFileSync, existsSync } from 'node:fs';
  2. import { execSync } from 'node:child_process';
  3. const root = 'd:/work/ylrz_saas';
  4. const files = execSync('git show --name-only --pretty=format: 5dfe60ed', { cwd: root })
  5. .toString('utf8')
  6. .split(/\r?\n/)
  7. .filter(Boolean);
  8. const issues = [];
  9. for (const rel of files) {
  10. const path = `${root}/${rel.replace(/\\/g, '/')}`;
  11. if (!existsSync(path)) continue;
  12. if (!/\.(java|js|vue|sql|xml|md)$/.test(rel)) continue;
  13. const raw = readFileSync(path);
  14. const text = raw.toString('utf8');
  15. const bom = raw.length >= 3 && raw[0] === 0xef && raw[1] === 0xbb && raw[2] === 0xbf;
  16. const fffd = text.includes('\uFFFD');
  17. const qmarks = /[^\s]\?{2,}[^\s?]|\?{4,}/.test(text);
  18. const latinGarble = /[\u00c0-\u00ff]{3,}/.test(text);
  19. if (bom || fffd || qmarks || latinGarble) {
  20. issues.push({ rel, bom, fffd, qmarks, latinGarble });
  21. }
  22. }
  23. console.log(JSON.stringify(issues, null, 2));
  24. console.log('count', issues.length);