1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00
Commit Graph

33 Commits

Author SHA1 Message Date
nnposter
e80976a13a Provides a common function, url.get_default_port(), for obtaining
the default port number for a given scheme. Fixes #781
2017-04-19 18:00:36 +00:00
nnposter
af6bbc35bb Changes the port type returned from url.parse() to an actual integer, as
opposed to a string that represents an integer. Fixes #833, fixes #817.
2017-04-19 17:02:32 +00:00
nnposter
5636767c85 Fixes hard-to-read code indentation 2017-04-01 21:11:47 +00:00
dmiller
ea58c6bebb Replace chained concatenation reassignment with simple concatenation
Example:

x = y
x = x .. z

Fixed:

x = y
.. z

This simple fix would save 1 string creation/deletion. Most changes
involve many more than this.
2015-03-02 13:47:42 +00:00
dmiller
5952b9745b Move url-encoding to url.build_query
patch from nnposter: http://seclists.org/nmap-dev/2014/q3/427
2014-10-15 18:12:58 +00:00
dmiller
1b71f75aad Spelling fixes for Lua files
Mostly in documentation/comments, but a couple code bugs were caught,
including a call to stdnse.pirnt_debug and a mis-declared variable.
2014-02-19 04:15:46 +00:00
dmiller
1c0c090ace Refactor some Lua string concatenations.
Using this regular expression, '\(\w*\)\s*=\s*\1\s*\.\.', found and
replaced many string concatenation-reassignments. These can cause
performance issues, since a new string gets allocated for each
reassignment. In many cases, the replacement is simply a single string,
wrapped across lines with the '\z' escape, which consumes a newline and
whitespace following it. In other cases, a table is used to hold the
substrings until the final string is built with a single table.concat
operation (same technique used in stdnse.strbuf).

Also, some string-building loops of this form:

s = ""
for i = 1, 100, 1 do
  s = s .. "\0"
end

were replaced with this much faster and cleaner version:

s = string.rep("\0", 100)
2014-02-18 18:10:23 +00:00
dmiller
961ea25225 Re-indent some NSE libraries.
https://secwiki.org/w/Nmap/Code_Standards
2014-02-03 19:47:34 +00:00
dmiller
620f9fdb34 Remove trailing whitespace in lua files
Whitespace is not significant, so this should not be a problem.
https://secwiki.org/w/Nmap/Code_Standards
2014-01-23 21:51:58 +00:00
david
4fb61350d8 url.parse should convert all schemes to lower case.
RFC 3986 section 3.1:
Although schemes are case-insensitive, the canonical form is lowercase
and documents that specify schemes must do so with lowercase letters.
An implementation should accept uppercase letters as equivalent to
lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the
sake of robustness but should only produce lowercase scheme names for
consistency.
2013-02-07 23:43:47 +00:00
david
a210d38769 Allow empty path in url.parse.
I got a redirect of "?p=indisponible" and url.parse returned
{query="p=indisponible"}. Now it returns
{path="", query="p=indisponible"}.
2013-02-07 22:37:38 +00:00
david
ac5a479a73 Treat empty port in URL the same as absent.
RFC 3986 says that these URLs are equivalent:

http://example.com/
http://example.com:/

url.parse was returning port="" for the latter. Make it instead return
port=nil like the former.
2013-02-07 03:06:30 +00:00
david
1c7c414fbb URL ports have to be decimal digits.
RFC 3986 section 3.2.3.
2013-02-07 03:06:29 +00:00
david
45b5d92f3d Don't treat an empty string as an invalid URL.
To me, this is a relative URL with a path of "". I.e., it refers to the
same document as wherever the URL appeared, like when people do
<form action="" enctype="multipart/form-data" method="POST">
2013-02-07 02:28:23 +00:00
david
bf69c6b5b9 port is part of a url table. 2012-08-02 04:29:56 +00:00
batrick
000f6dc4d9 Lua 5.2 upgrade [1] for NSE.
[1] http://seclists.org/nmap-dev/2012/q2/34
2012-05-27 08:53:32 +00:00
david
33fa3fae76 Summarize URL tables in url.lua NSEDoc. 2012-03-05 23:00:49 +00:00
batrick
4444071f03 use # length operator instead of string.len (canonicalize)
Used this perl command:

$ # perl -pi -e 's/string\.len\((.*?)\)/#\1/g' *.lua

Also fixed one instance where the above command didn't correctly
translate the intended code (string.len(a .. b .. c)).
2011-05-11 15:08:55 +00:00
batrick
186cb2d6a3 canonicalize some code 2011-05-11 14:38:52 +00:00
david
7d0c08a097 Brief copyediting of NSEDoc for modules. 2010-07-12 19:42:43 +00:00
batrick
90a712ae2b Patch to libraries that were inappropriately using globals.
Often two (or more) scripts using the same library would
overwrite the globals each was using. This would result
in (at best) an error or (at worst) a deadlock.

The patch changes the global accesses to local.
2009-07-07 00:20:52 +00:00
david
5f166e19ec Don't use empty parentheses when referring to functions by name in NSE
documentation.
2008-11-07 22:49:49 +00:00
david
af4497669b Proofread and update documentation of pop3, shortport, snmp, ssh1, ssh2,
strbuf, tab, unpwdb, and url.
2008-10-24 20:12:36 +00:00
david
3ee17ecb5c Fix NSEDoc error messages, except for some "documenting undefined parameter"
that happen when one function is defined to be another by assignment.
2008-10-24 17:05:40 +00:00
david
99c30b1d1b Merge documetation for unpwdb, url, bit, tab, base64, and bin. 2008-10-16 03:18:03 +00:00
batrick
670792a4a6 Updated all libraries documentation.
packet and url both need more work.
2008-08-18 04:03:45 +00:00
batrick
462c289f4a Fixed all the modules to give a default name if absent.
Also necessary for the documentation system to know the name
of the module.
2008-08-16 04:20:15 +00:00
fyodor
454e4e3b17 I hope this will recover nselib history 2007-11-27 22:50:00 +00:00
fyodor
bbb0744761 now move nselib to recover history 2007-11-27 22:42:39 +00:00
diman
c0f07c99ac adding nselib nselib-bin second (should work on unix now) 2007-11-27 22:18:59 +00:00
diman
335ec2868f adding nselib and nselib-bin the first 2007-11-27 22:17:30 +00:00
fyodor
475393bc2c merge soc07 r5049:5063 - added string split/join methods; Bruteforce telnet script; fixed a few typos; updated to escape some common url constructs; refactored shorport library; Added a family of string buffer functions to nselib as concatenation is not efficient; Updated a couple of scripts to use string buffers; resolved a couple of naming conflicts 2007-08-11 04:58:05 +00:00
fyodor
83ec445bcf merge soc07 r5005:5013 - URL manipulation lib from LuaSocket with a couple funcs added; added garbage collection for nsock-objects in lua 2007-08-11 04:46:43 +00:00