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

Detecting javascript code

Expand Messages
  • zbordie_flickr
    Hi there, I m trying to build a tool that detects javascript code in any kind of language or file format, for example PHP, ASP.NET, etc. . Not just HTML. Since
    Message 1 of 3 , Feb 26, 2011
    • 0 Attachment
      Hi there,

      I'm trying to build a tool that detects javascript code in any kind of language or file format, for example PHP, ASP.NET, etc. . Not just HTML.
      Since JSlint is a javascript validator do you think it's possible to use it (with the right transformations) to do this?
      My strategy would be, assuming the javascript is correct, the lines where JSLint tells me there is an error, it should be other thing that js.

      Do you think it's possible to do that? What kind of modifications should I do to JSlink to get this thing to work?
      Do you know any tools that do this already?

      Thank you,
      Bruno Costa (Portugal)
    • Douglas Crockford
      ... JSLint contains an XML parser. A very early version of JSLint tried to use it to do what you are suggesting. The difficulty of looking for script in PHP
      Message 2 of 3 , Feb 26, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "zbordie_flickr" <zbordie@...> wrote:
        > I'm trying to build a tool that detects javascript code in any kind of language or file format, for example PHP, ASP.NET, etc. . Not just HTML.
        > Since JSlint is a javascript validator do you think it's possible to use it (with the right transformations) to do this?
        > My strategy would be, assuming the javascript is correct, the lines where JSLint tells me there is an error, it should be other thing that js.
        >
        > Do you think it's possible to do that? What kind of modifications should I do to JSlink to get this thing to work?

        JSLint contains an XML parser. A very early version of JSLint tried to use it to do what you are suggesting. The difficulty of looking for script in PHP files is that parts of the script are likely to be generated dynamically, and JSLint is not given the dynamic result. So it is only able to work on completely static scripts. But it is smarter to put static scripts in a script file, not in the PHP, so the option to lint scripts in PHP files was useless and I removed it.
      • zbordie_flickr
        Like I said, I m not trying to validate the JS. I m trying to find out where it starts and where it ends. I have no problem with dynamically generated code.
        Message 3 of 3 , Feb 28, 2011
        • 0 Attachment
          Like I said, I'm not trying to validate the JS. I'm trying to find out where it starts and where it ends. I have no problem with dynamically generated code. For my current project, I really need this feature.

          Is possible to do what I'm trying here?
          If so, could you give me any hints on how to modify it to do that?

          Thanks ;)
        Your message has been successfully submitted and would be delivered to recipients shortly.