Skip to content

Commit

Permalink
fixing parser to accept malformed userinfo (non-encoded email address…
Browse files Browse the repository at this point in the history
…) - closes #108
  • Loading branch information
rodneyrehm committed Aug 14, 2013
1 parent f0dd0c5 commit aa66fa7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m
### `[dev-version]` (master branch) ###

* fixing regression for Node.js introduced by `fixing unsafe eval by using UMD's root` - ([Issue #107](https://github.com/medialize/URI.js/issues/107))
* fixing parser to accept malformed userinfo (non-encoded email address) - ([Issue #108](https://github.com/medialize/URI.js/issues/108))

### 1.11.1 (August 13th 2013) ###

Expand Down
4 changes: 3 additions & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,10 @@ URI.parseAuthority = function(string, parts) {
};
URI.parseUserinfo = function(string, parts) {
// extract username:password
var pos = string.indexOf('@');
var firstSlash = string.indexOf('/');
var pos = firstSlash > -1
? string.lastIndexOf('@', firstSlash)
: string.indexOf('@');
var t;

// authority@ must come before /path
Expand Down
48 changes: 48 additions & 0 deletions test/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,54 @@ var urls = [{
idn: false,
punycode: false
}
}, {
name: 'malformed email in userinfo',
url: 'scheme://john@doe.com:pass:word@www.example.org/',
_url: 'scheme://john%40doe.com:pass%3Aword@www.example.org/',
parts: {
protocol: 'scheme',
username: 'john@doe.com',
password: 'pass:word',
hostname: 'www.example.org',
port: null,
path: '/',
query: null,
fragment: null
},
accessors: {
protocol: 'scheme',
username: 'john@doe.com',
password: 'pass:word',
port: '',
path: '/',
query: '',
fragment: '',
resource: '/',
authority: 'john%40doe.com:pass%3Aword@www.example.org',
userinfo: 'john%40doe.com:pass%3Aword',
subdomain: 'www',
domain: 'example.org',
tld: 'org',
directory: '/',
filename: '',
suffix: '',
hash: '',
search: '',
host: 'www.example.org',
hostname: 'www.example.org'
},
is: {
urn: false,
url: true,
relative: false,
name: true,
sld: false,
ip: false,
ip4: false,
ip6: false,
idn: false,
punycode: false
}
}, {
name: 'host-relative: URL',
url: '/some/directory/file.html?query=string#fragment',
Expand Down

0 comments on commit aa66fa7

Please sign in to comment.