Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

response.write("<html><body>NODE<script src='core.js' type='text/javascript'></script></body></html>") #2154

Closed
neechange opened this issue Nov 20, 2011 · 13 comments

Comments

@neechange
Copy link

response.write("<html><body>NODE<script src='core.js' type='text/javascript'></script></body></html>")

<script src='core.js' type='text/javascript'></script> Do not perform?

@neechange
Copy link
Author

script Do not perform?

@aslilac
Copy link

aslilac commented Nov 20, 2011

Because 'core.js' and ''text/javascript' both use single quotes, just like the string you want them to be inside of. Try..

response.write('<html><body>NODE<script src="core.js" type="text/javascript"></script></body></html>')

Also, if the response is hard coded, core.js will say the exact same thing as the page loading it in, and throw an error. But that's not what the issue is about, so let's close this one, yes?

@neechange
Copy link
Author

I think this problem should be handled rather than close ..text/html

@neechange
Copy link
Author

NODE<script src="core.js" type="text/javascript"></script><script type="text/javascript">for(var i-0;i<10;i++){document.write(i)}</script>

The two label is not the same as you, why can a

@neechange
Copy link
Author

两个标签不一样吗,一个为什么可以

@aslilac
Copy link

aslilac commented Nov 20, 2011

Handling it would require far too much effort, and would turn Node into an improper JavaScript implementation. The language definition says that your code is incorrect, and we will not make a major change the language simply for one person who's obviously new to JavaScript, and is too lazy/stupid to use correct quotation techniques.

@ghost
Copy link

ghost commented Nov 20, 2011

This is the most important bug this week and I demand it be fixed

@sipefree
Copy link

Showstopper. I can't believe a bug like this would make it into a release.

I'm going back to PHP.

@neechange
Copy link
Author

Double quotes can solve the problem?

@isaacs
Copy link

isaacs commented Nov 21, 2011

@neechange

  1. It's almost impossible to tell what problem you're seeing without seeing the entire program. You can get better results posting the whole thing to http://gist.github.com and then sharing a link.
  2. This issues list is for bugs in node itself. If you're struggling trying to figure out how to use node, please see the IRC channel and mailing list. There are a lot of links here: https://github.com/joyent/node/wiki/Community

@neechange
Copy link
Author

var http = require("http"),fs = require("fs"),path = require("path"),url = require("url");
var server = http.createServer(function(req, res){
var txt=fs.readFileSync(__dirname.replace(//,'/')+'/index.html','utf8');
console.log(txt);
var a=txt.match(/<script[^>]?>.?</script>/g)
for(var i=0;i<a.length;i++){
txt=txt.replace(a[i],"<script type='text/javascript'>"+fs.readFileSync(__dirname.replace(//,'/')+'/'+a[i].match(/src='[^']*'/g)[0].replace(/(src=)|'||"/g,''),'utf8')+"</script>")
}

res.writeHead(200, {'Content-Type': 'text/html'});
res.end(txt)

}).listen(3000);

@neechange
Copy link
Author

@isaacs
Copy link

isaacs commented Nov 22, 2011

@neechange You're serving html for every request, including requests for javascript files.

This issues list is not the place for such things. You need to post this on the user list. If you post it there, I or someone else will gladly help you. http://groups.google.com/group/nodejs

Or, you can share your gist in IRC. More links: https://github.com/joyent/node/wiki/Community

wiedi pushed a commit to wiedi/node that referenced this issue Aug 15, 2015
Notable changes:

* buffer:
  - Due to changes in V8, it has been necessary to reimplement Buffer
    on top of V8's Uint8Array. While every effort has been made to
    maintain performance, users are likely to experience a different
    performance profile depending on how Buffer is used.
    (Trevor Norris) nodejs#1825.
  - Buffer can now take ArrayBuffers as a constructor argument
    (Trevor Norris) nodejs#2002.
  - When a single buffer is passed to Buffer.concat(), a new, copied
    Buffer object will be returned; previous behavior was to return
    the original Buffer object (Sakthipriyan Vairamani) nodejs#1937.
* build: PPC support has been added to core to allow compiling on
  pLinux BE and LE (AIX support coming soon) (Michael Dawson) nodejs#2124.
* dgram: If an error occurs within socket.send() and a callback has
  been provided, the error is only passed as the first argument to the
  callback and not emitted on the socket object; previous behavior was
  to do both (Matteo Collina & Chris Dickinson) nodejs#1796
* freelist: Deprecate the undocumented freelist core module
  (Sakthipriyan Vairamani) nodejs#2176.
* http:
  - Status codes now all use the official IANA names as per RFC7231,
    e.g. http.STATUS_CODES[414] now returns 'URI Too Long' rather than
    'Request-URI Too Large' (jomo) nodejs#1470.
  - Calling .getName() on an HTTP agent no longer returns a trailing
    colon, HTTPS agents will no longer return an extra colon near the
    middle of the string (Brendan Ashworth) nodejs#1617.
* node:
  - NODE_MODULE_VERSION has been bumped to 45 to reflect the break in
    ABI (Rod Vagg) nodejs#2096.
  - Introduce a new process.release object that contains a name
    property set to 'io.js' and sourceUrl, headersUrl and libUrl
    (Windows only) properties containing URLs for the relevant
    resources; this is intended to be used by node-gyp
    (Rod Vagg) nodejs#2154.
  - The version of node-gyp bundled with io.js now downloads and uses
    a tarball of header files from iojs.org rather than the full
    source for compiling native add-ons; it is hoped this is a
    temporary floating patch and the change will be upstreamed to
    node-gyp soon (Rod Vagg) nodejs#2066.
* repl: Persistent history is now enabled by default. The history file
  is located at ~/.node_repl_history, which can be overridden by the
  new environment variable NODE_REPL_HISTORY. This deprecates the
  previous NODE_REPL_HISTORY_FILE variable. Additionally, the format
  of the file has been changed to plain text to better handle file
  corruption. (Jeremiah Senkpiel) nodejs#2224.
* smalloc: The smalloc module has been removed as it is no longer
  possible to provide the API due to changes in V8
  (Ben Noordhuis) nodejs#2022.
* tls: Add server.getTicketKeys() and server.setTicketKeys() methods
  for TLS session key rotation (Fedor Indutny) nodejs#2227.
* v8: Upgraded to 4.4.63.26
  - ES6: Enabled computed property names
  - ES6: Array can now be subclassed in strict mode
  - ES6: Implement rest parameters in staging, use the
    --harmony-rest-parameters command line flag
  - ES6: Implement the spread operator in staging, use the
    --harmony-spreadcalls command line flag
  - Removed SetIndexedPropertiesToExternalArrayData and related APIs,
    forcing a shift to Buffer to be reimplemented based on Uint8Array
  - Introduction of Maybe and MaybeLocal C++ API for objects which may
    or may not have a value.
  - Added support for PPC

PR-URL: nodejs/node#2299
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants