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

feat: remove cheerio dependency #627

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
31 changes: 11 additions & 20 deletions protocols/buildandshoot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Core from './core.js'
import * as cheerio from 'cheerio'

export default class buildandshoot extends Core {
async run (state) {
Expand Down Expand Up @@ -29,27 +28,19 @@
state.connect = m[0]
}

const $ = cheerio.load(body)
$('#playerlist tbody tr').each((i, tr) => {
if (!$(tr).find('td').first().attr('colspan')) {
const playerListRegex = /<tr>(.*?)<\/tr>/g
let playerMatch
while ((playerMatch = playerListRegex.exec(body)) !== null) {
const playerRow = playerMatch[1]
const cols = playerRow.match(/<td.*?>(.*?)<\/td>/g)
if (cols && cols.length > 1 && !cols[0].includes('colspan')) {
state.players.push({
name: $(tr).find('td').eq(2).text(),
ping: $(tr).find('td').eq(3).text().trim(),
team: $(tr).find('td').eq(4).text().toLowerCase(),
score: parseInt($(tr).find('td').eq(5).text())
name: cols[2].replace(/<.*?>/g, '').trim(),

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
ping: cols[3].replace(/<.*?>/g, '').trim(),

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
team: cols[4].replace(/<.*?>/g, '').toLowerCase().trim(),

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
score: parseInt(cols[5].replace(/<.*?>/g, '').trim())

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
})
}
})
/*
var m = this.options.address.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
if(m) {
var o1 = parseInt(m[1]);
var o2 = parseInt(m[2]);
var o3 = parseInt(m[3]);
var o4 = parseInt(m[4]);
var addr = o1+(o2<<8)+(o3<<16)+(o4<<24);
state.raw.url = 'aos://'+addr;
}
*/
}
}
}
Loading