File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,10 +145,10 @@ function stringToPaddedHex(numberString) {
145145 */
146146function testBit ( binaryValue , position ) {
147147 const { length } = binaryValue ;
148- if ( position > length ) {
148+ if ( position >= length ) {
149149 return false ;
150150 }
151- const positionInString = length - position ;
151+ const positionInString = length - position - 1 ;
152152 return binaryValue . substring ( positionInString , positionInString + 1 ) === '1' ;
153153}
154154//# sourceMappingURL=common.js.map
Original file line number Diff line number Diff line change @@ -235,6 +235,13 @@ class Address4 {
235235 * address.correctForm(); // '192.0.2.42'
236236 */
237237 static fromArpa ( arpaFormAddress ) {
238+ // A 15-character address, a "/32" prefix length and ".in-addr.arpa.": the
239+ // longest name is 32 characters. Longer input is rejected before its
240+ // labels are split, as the constructor does at its own limit.
241+ const longest = constants . GROUPS * 4 - 1 + '/32' . length + '.in-addr.arpa.' . length ;
242+ if ( arpaFormAddress . length > longest ) {
243+ throw new address_error_1 . AddressError ( `in-addr.arpa names are at most ${ longest } characters.` ) ;
244+ }
238245 // remove an ending ".in-addr.arpa", in any case and with or without the
239246 // root dot, as Address6.fromArpa does for ".ip6.arpa"
240247 const leader = arpaFormAddress . replace ( / ( \. i n - a d d r \. a r p a ) ? \. ? $ / i, '' ) ;
Original file line number Diff line number Diff line change @@ -139,10 +139,13 @@ class Address6 {
139139 if ( / \/ / . test ( address ) ) {
140140 throw new address_error_1 . AddressError ( 'Invalid subnet mask.' ) ;
141141 }
142- const zone = constants6 . RE_ZONE_STRING . exec ( address ) ;
143- if ( zone ) {
144- this . zone = zone [ 0 ] ;
145- address = address . replace ( constants6 . RE_ZONE_STRING , '' ) ;
142+ // A zone runs from the first `%` to the end of the input and holds no line
143+ // terminator. Finding it by index reads the input once, where matching
144+ // RE_ZONE_STRING retries from every `%` that a line terminator disqualifies.
145+ const zoneStart = address . indexOf ( '%' ) ;
146+ if ( zoneStart !== - 1 && / ^ .* $ / . test ( address . slice ( zoneStart ) ) ) {
147+ this . zone = address . slice ( zoneStart ) ;
148+ address = address . slice ( 0 , zoneStart ) ;
146149 }
147150 // The longest well-formed address is all but the last two groups written
148151 // as four hex digits with their colons, then a 15-character dotted quad:
Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ exports.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
8181 * A regular expression that matches an IPv6 zone
8282 * @memberof Address6
8383 * @static
84+ * @deprecated Takes quadratic time on input holding many `%` characters
85+ * followed by a line terminator. The library finds the zone by index, as
86+ * `Address6`'s constructor shows, and 11.0.0 removes this export.
8487 */
8588exports . RE_ZONE_STRING = / % .* $ / ;
8689exports . RE_URL = / ^ (?: \[ ( [ 0 - 9 a - f : . ] + ) \] | ( [ 0 - 9 a - f : . ] + ) ) (?: [ / ? # ] .* ) ? $ / i;
Original file line number Diff line number Diff line change 1616 " bigint" ,
1717 " browser"
1818 ],
19- "version" : " 10.7.2 " ,
19+ "version" : " 10.7.5 " ,
2020 "author" :
" Beau Gunderson <[email protected] > (https://beaugunderson.com/)" ,
2121 "license" : " MIT" ,
2222 "main" : " dist/ip-address.js" ,
2323 "types" : " dist/ip-address.d.ts" ,
2424 "scripts" : {
2525 "docs" : " tsx scripts/build-readme.ts" ,
26+ "docs:check" : " tsx scripts/build-readme.ts --check" ,
2627 "build" : " rm -rf dist; mkdir dist; tsc" ,
2728 "prepack" : " npm run docs && npm run build" ,
2829 "prepare" : " git config core.hooksPath hooks || true" ,
7980 "eslint-plugin-import" : " ^2.32.0" ,
8081 "eslint-plugin-prettier" : " ^5.5.5" ,
8182 "eslint-plugin-sort-imports-es6-autofix" : " ^0.6.0" ,
82- "mocha" : " ^11.7.5 " ,
83+ "mocha" : " ^12.0.3 " ,
8384 "monocart-coverage-reports" : " ^2.12.11" ,
8485 "prettier" : " ^3.8.3" ,
8586 "source-map-support" : " ^0.5.21" ,
Original file line number Diff line number Diff line change 67126712 }
67136713 },
67146714 "node_modules/ip-address" : {
6715- "version" : " 10.7.2 " ,
6716- "resolved" : " https://registry.npmjs.org/ip-address/-/ip-address-10.7.2 .tgz" ,
6717- "integrity" : " sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w ==" ,
6715+ "version" : " 10.7.5 " ,
6716+ "resolved" : " https://registry.npmjs.org/ip-address/-/ip-address-10.7.5 .tgz" ,
6717+ "integrity" : " sha512-t2v0rkILYv9WXmSL7TpAaU3HXgaFYOPUcH3QHgwQ++gpJuH3bqyMy4Fvt/DJCTKwzH3Cf+bAp5W/mFL39KPLzA ==" ,
67186718 "inBundle" : true ,
67196719 "license" : " MIT" ,
67206720 "engines" : {
You can’t perform that action at this time.
0 commit comments