Project

General

Profile

« Previous | Next » 

Revision b9a6179c

Added by koszko over 1 year ago

fix payload creation for file:// URLs

View differences:

common/patterns.js
192 192

  
193 193
function reconstruct_url(deco)
194 194
{
195
    const domain = deco.domain.join(".");
195
    const domain = (deco.domain || []).join(".");
196 196
    const path = ["", ...deco.path].join("/");
197 197
    const trail = deco.trailing_slash ? "/" : "";
198 198
    return `${deco.proto}://${domain}${path}${trail}`;
test/haketilo_test/unit/test_patterns.py
103 103
    assert deco['domain']         == ['example', 'com']
104 104
    assert deco['path']           == ['a', 'b']
105 105

  
106
    reco = execute_in_page('returnval(reconstruct_url(arguments[0]));', deco)
107
    assert reco == 'https://example.com/a/b'
108

  
106 109
    deco = execute_in_page('returnval(deconstruct_url(arguments[0]));',
107 110
                           'http://**.example.com/')
108 111
    assert deco
......
111 114
    assert deco['domain']         == ['**', 'example', 'com']
112 115
    assert deco['path']           == []
113 116

  
117
    reco = execute_in_page('returnval(reconstruct_url(arguments[0]));', deco)
118
    assert reco == 'http://**.example.com/'
119

  
114 120
    deco = execute_in_page('returnval(deconstruct_url(arguments[0]));',
115 121
                           'ftp://user@ftp.example.com/all///passwords.txt/')
116 122
    assert deco
......
119 125
    assert deco['domain']         == ['ftp', 'example', 'com']
120 126
    assert deco['path']           == ['all', 'passwords.txt']
121 127

  
128
    reco = execute_in_page('returnval(reconstruct_url(arguments[0]));', deco)
129
    assert reco == 'ftp://ftp.example.com/all/passwords.txt/'
130

  
122 131
    deco = execute_in_page('returnval(deconstruct_url(arguments[0]));',
123 132
                           'ftp://mirror.edu.pl.eu.org')
124 133
    assert deco
......
127 136
    assert deco['domain']         == ['mirror', 'edu', 'pl', 'eu', 'org']
128 137
    assert deco['path']           == []
129 138

  
139
    reco = execute_in_page('returnval(reconstruct_url(arguments[0]));', deco)
140
    assert reco == 'ftp://mirror.edu.pl.eu.org'
141

  
130 142
    deco = execute_in_page('returnval(deconstruct_url(arguments[0]));',
131 143
                           'file:///mnt/parabola_chroot///etc/passwd')
132 144
    assert deco
......
135 147
    assert deco['path']           == ['mnt', 'parabola_chroot', 'etc', 'passwd']
136 148
    assert 'domain' not in deco
137 149

  
150
    reco = execute_in_page('returnval(reconstruct_url(arguments[0]));', deco)
151
    assert reco == 'file:///mnt/parabola_chroot/etc/passwd'
152

  
138 153
    for bad_url in [
139 154
            '://bad-url.missing/protocol',
140 155
            'http:/example.com/a/b',

Also available in: Unified diff