Fix netquery textql parser when dealing with IP addresses

This commit is contained in:
Patrick Pacher 2024-03-29 09:35:18 +01:00
parent 0e5b8b2e06
commit 6daea521c3
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
2 changed files with 60 additions and 10 deletions

View file

@ -0,0 +1,51 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
],
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
],
"rules": {
"@angular-eslint/template/click-events-have-key-events": "off",
"@angular-eslint/template/interactive-supports-focus": "off"
}
}
]
}

View file

@ -43,7 +43,7 @@ export class Lexer {
} }
/** reads a number token */ /** reads a number token */
private readNumber(): Token<TokenType.NUMBER> { private readNumber(): Token<TokenType.NUMBER> | null {
const start = this._input.pos; const start = this._input.pos;
let has_dot = false; let has_dot = false;
@ -59,9 +59,10 @@ export class Lexer {
return isDigit(ch); return isDigit(ch);
}); });
if (!this._input.eof() && isIdentChar(this._input.peek())) { if (!this._input.eof() && !isWhitespace(this._input.peek())) {
this._input.revert(number.length + 1); this._input.revert(number.length);
this._input.croak("invalid number character")
return null;
} }
return { return {
@ -182,13 +183,11 @@ export class Lexer {
return this.readString('\'', true); return this.readString('\'', true);
} }
try { if (isDigit(ch)) {
if (isDigit(ch)) { const number = this.readNumber();
return this.readNumber(); if (number !== null) {
return number;
} }
} catch (err) {
// we ignore that error here as it may only happen for unqoted strings
// that start with a number.
} }
if (ch === ':') { if (ch === ':') {