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

Error with printing command due to incomplete regex match #75

Closed
feute opened this issue Apr 10, 2018 · 0 comments
Closed

Error with printing command due to incomplete regex match #75

feute opened this issue Apr 10, 2018 · 0 comments

Comments

@feute
Copy link
Contributor

feute commented Apr 10, 2018

I'm trying to print information from a hotspot using /ip/hotspot/print, here is the code:

const device = new MikroNode(ip);
device.connect()
  .then(([login]) => {
    return login(user, pass);
  })
  .then((conn) => {
    conn.closeOnDone(true);
    const chan = conn.openChannel();
    chan.write('/ip/hotspot/print');
    chan.done.subscribe((e) => {
      console.log(e);
      res.send({ data: e });
    });
  });

When I try to test it, it throws a stack trace with the error Expected [.a-z\\-0-9] but "H" found.. Here is the complete stack trace:

Error processing sentence: { SyntaxError: Expected [.a-z\-0-9] but "H" found.
    at peg$buildStructuredError (server/node_modules/mikronode/dist/mikronode.js:2174:13)
    at Object.peg$parse [as parse] (server/node_modules/mikronode/dist/mikronode.js:3201:12)
    at MapSubscriber.project (server/node_modules/mikronode/dist/mikronode.js:486:39)
    at MapSubscriber._next (server/node_modules/rxjs/operators/map.js:79:35)
    at MapSubscriber.Subscriber.next (server/node_modules/rxjs/Subscriber.js:93:18)
    at MapSubscriber._next (server/node_modules/rxjs/operators/map.js:85:26)
    at MapSubscriber.Subscriber.next (server/node_modules/rxjs/Subscriber.js:93:18)
    at DoSubscriber._next (server/node_modules/rxjs/operators/tap.js:88:30)
    at DoSubscriber.Subscriber.next (server/node_modules/rxjs/Subscriber.js:93:18)
    at Subject.next (server/node_modules/rxjs/Subject.js:55:25)
    at ScanSubscriber.accumulator (server/node_modules/mikronode/dist/mikronode.js:529:41)
    at ScanSubscriber._tryNext (server/node_modules/rxjs/operators/scan.js:111:27)
    at ScanSubscriber._next (server/node_modules/rxjs/operators/scan.js:104:25)
    at ScanSubscriber.Subscriber.next (server/node_modules/rxjs/Subscriber.js:93:18)
    at Socket.handler (server/node_modules/rxjs/observable/FromEventObservable.js:210:46)
    at emitOne (events.js:116:13)
  message: 'Expected [.a-z\\-0-9] but "H" found.',
  expected:
   [ { type: 'class',
       parts: [Array],
       inverted: false,
       ignoreCase: false } ],
  found: 'H',
  location:
   { start: { offset: 226, line: 14, column: 2 },
     end: { offset: 227, line: 14, column: 3 } },
  name: 'SyntaxError' }
Skipping and continuing

After a little while of debugging, I figured that the regex that is trying to execute is incomplete, as it doesn't include capital letters, and from the hotspot information, there is a field HTTPS, so the regex fails at that point. The line from the mikronode dist file causing this is at line 1974:

peg$c13 = /^[.a-z\-0-9]/,

After changing it to /^[.a-zA-Z\-0-9]/ it works as expected.

I'd be happy to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant