Loading ...
Sorry, an error occurred while loading the content.

SV: [jslint] Re: Bad HTML string?

Expand Messages
  • Jakob Kruse
    Ah yes. Thanks Harry. Obviously the error is partly mine. The “Bad HTML string” error seems to be caused by an internal JSLint error on an earlier run. If
    Message 1 of 6 , Feb 3, 2012
    • 0 Attachment
      Ah yes. Thanks Harry.

      Obviously the error is partly mine. The “Bad HTML string” error seems to be caused by an internal JSLint error on an earlier run. If you check this piece of HTML first (web interface is fine), then check the JavaScript piece again, you should see the error:

      <html>
      <head>
      <script type="text/javascript">
      /*jslint sloppy: true, on: true */
      </script>
      </head>
      <body onselectstart="return false;">
      </body>
      </html>

      The error seems to be in JSLints indentation check of the “onselectstart” attribute.

      /Jakob

      Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af Merlin
      Sendt: 3. februar 2012 12:50
      Til: jslint_com@yahoogroups.com
      Emne: [jslint] Re: Bad HTML string?


      --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
      > If I run the following code (properly indented) through JSLint at jslint.com with all options cleared, it validates. If I run the exact same code through JSLint locally, with no options, using jslint.js downloaded today from jslint.com, it errors with "Bad HTML string".
      >
      > /*jslint sloppy: true */
      > function quote(s) {
      > return '"' + s + '"';
      > }
      >
      > Any ideas as to the difference?

      I've tried linting the file t.js on both the full and minimized versions of jslint
      in Widget Tester. I'm not seeing the fault in either version.

      Using file from http://jslint.com/jslint.js:

      Welcome to Yahoo! Widgets 4.5.2x10A50 on 02/03/12 11:26:46.066
      getJSLint:Using local JSLint file. MD5 sum: 1467142763141787501a2c3f745d303f
      Widget Tester 9.4.4
      JSLint by Douglas Crockford, Edition 2012-01-26.
      Filename: t.js
      ok

      Using file from http://www.JSLint.com/minjslint.js:

      Welcome to Yahoo! Widgets 4.5.2x10A50 on 02/03/12 11:28:07.856
      getJSLint:Using today's JSLint file. MD5 sum: 73152b10706369d0c7dbea86751e12c6
      Widget Tester 9.4.4
      JSLint by Douglas Crockford, Edition 2012-01-26.
      Filename: t.js
      ok

      t.js:
      /*jslint sloppy: true */
      function quote(s) {
      return '"' + s + '"';
      }

      (Tried it with a tab and with four spaces.)

      Harry.

      [Non-text portions of this message have been removed]
    • Merlin
      ... Using Widget Tester: Welcome to Yahoo! Widgets 4.5.2x10A50 on 02/03/12 13:52:08.937 getJSLint:Using today s JSLint file. MD5 sum:
      Message 2 of 6 , Feb 3, 2012
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
        >
        > Ah yes. Thanks Harry.
        >
        > Obviously the error is partly mine. The "Bad HTML string" error seems to be caused by an internal JSLint error on an earlier run. If you check this piece of HTML first (web interface is fine), then check the JavaScript piece again, you should see the error:

        Using Widget Tester:

        Welcome to Yahoo! Widgets 4.5.2x10A50 on 02/03/12 13:52:08.937
        getJSLint:Using today's JSLint file. MD5 sum: 73152b10706369d0c7dbea86751e12c6
        Widget Tester 9.4.4
        JSLint by Douglas Crockford, Edition 2012-01-26.

        Filename: t.js
        ok <<< first run OK

        Filename: html.html
        Working
        Lint at line 7 character 22: indent has no properties << html.html file gives error

        Filename: t.js
        Working
        Lint at line 3 character 13: Bad HTML string <<< second run fails

        html.html:
        <html>
        <head>
        <script type="text/javascript">
        /*jslint sloppy: true, on: true */
        </script>
        </head>
        <body onselectstart="return false;">
        </body>
        </html>

        t.js:
        /*jslint sloppy: true */
        function quote(s) {
        return '"' + s + '"';
        }


        Using the web version at http://www.JSLint.com/

        html.html:
        Error:
        Problem at line 192 character 22: 'null' is not an object (evaluating 'indent.at')

        t.js:
        Error:
        Problem at line 3 character 13: Bad HTML string

        return '"' + s + '"';

        It appears that JSLint is retaining state from one run to the next.

        The web and Widget Tester versions both fail, but not quite in the same way.

        Harry.
      • Jakob Kruse
        ... In case of internal errors, yes. ... Actually, they fail in exactly the same way, but the error message given for this error by different JavaScript
        Message 3 of 6 , Feb 3, 2012
        • 0 Attachment
          > It appears that JSLint is retaining state from one run to the next.

          In case of internal errors, yes.

          > The web and Widget Tester versions both fail, but not quite in the same way.

          Actually, they fail in exactly the same way, but the error message given for this error by different JavaScript runtimes differs. Try running the web validation in Chrome for instance, and you will get a third error message.

          /Jakob
        • Merlin
          ... Confirmed: In Chrome: Error: Problem at line 7 character 22: Cannot read property at of null Over to Douglas! Harry.
          Message 4 of 6 , Feb 3, 2012
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
            > > It appears that JSLint is retaining state from one run to the next.
            > In case of internal errors, yes.
            > > The web and Widget Tester versions both fail, but not quite in the same way.

            > Actually, they fail in exactly the same way, but the error message given for this error by different JavaScript runtimes differs. Try running the web validation in Chrome for instance, and you will get a third error message.

            Confirmed:
            In Chrome:
            Error:
            Problem at line 7 character 22: Cannot read property 'at' of null

            Over to Douglas!

            Harry.
          • douglascrockford
            ... Thanks. Please try it now. And by the way, in case anyone has been reading this thread, function quote(s) { return + s + ; } is a dangerously
            Message 5 of 6 , Feb 3, 2012
            • 0 Attachment
              --- In jslint_com@yahoogroups.com, "Merlin" <g7awz@...> wrote:
              >
              > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
              > > > It appears that JSLint is retaining state from one run to the next.
              > > In case of internal errors, yes.
              > > > The web and Widget Tester versions both fail, but not quite in the same way.
              >
              > > Actually, they fail in exactly the same way, but the error message given for this error by different JavaScript runtimes differs. Try running the web validation in Chrome for instance, and you will get a third error message.
              >
              > Confirmed:
              > In Chrome:
              > Error:
              > Problem at line 7 character 22: Cannot read property 'at' of null


              Thanks. Please try it now.

              And by the way, in case anyone has been reading this thread,

              function quote(s) {
              return '"' + s + '"';
              }

              is a dangerously insecure function. It should be removing or entityifying all '"' and '\\' in s before concatenating.
            • Jakob Kruse
              Works, thanks! And yes, don’t ever use that function or anything like it. It was a bad example. /Jakob Fra: jslint_com@yahoogroups.com
              Message 6 of 6 , Feb 3, 2012
              • 0 Attachment
                Works, thanks! And yes, don’t ever use that function or anything like it. It was a bad example.

                /Jakob

                Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af douglascrockford
                Sendt: 3. februar 2012 19:04
                Til: jslint_com@yahoogroups.com
                Emne: SV: [jslint] Re: Bad HTML string?

                --- In jslint_com@yahoogroups.com, "Merlin" <g7awz@...> wrote:
                >
                > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
                > > > It appears that JSLint is retaining state from one run to the next.
                > > In case of internal errors, yes.
                > > > The web and Widget Tester versions both fail, but not quite in the same way.
                >
                > > Actually, they fail in exactly the same way, but the error message given for this error by different JavaScript runtimes differs. Try running the web validation in Chrome for instance, and you will get a third error message.
                >
                > Confirmed:
                > In Chrome:
                > Error:
                > Problem at line 7 character 22: Cannot read property 'at' of null

                Thanks. Please try it now.

                And by the way, in case anyone has been reading this thread,

                function quote(s) {
                return '"' + s + '"';
                }

                is a dangerously insecure function. It should be removing or entityifying all '"' and '\\' in s before concatenating.

                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.