# # # add_dir "tests/skip_invalid_paths" # # add_file "tests/skip_invalid_paths/__driver__.lua" # content [66292299b8a1784a6ebb57ac6ae708513c1ae026] # # patch "NEWS" # from [624126fa333f962c6ce80684adf755a00552b90a] # to [629cedfc5e6164fc8ea78616061d4712d557ce2a] # # patch "file_io.cc" # from [34e9c1581a7c336b0406c2601ac7cee5012723c7] # to [1c79107b3af55f17b13b5dae75d1e5dc3448e59f] # ============================================================ --- tests/skip_invalid_paths/__driver__.lua 66292299b8a1784a6ebb57ac6ae708513c1ae026 +++ tests/skip_invalid_paths/__driver__.lua 66292299b8a1784a6ebb57ac6ae708513c1ae026 @@ -0,0 +1,17 @@ + +-- we can't create the test files which trigger the warnings on win anyways +skip_if(ostype=="Windows") + +mtn_setup() + +mkdir("foo") +writefile("foo/\\", "invalid path") + +check(mtn("add", "foo"), 0, false, true) +check(qgrep("skipping invalid path '\\\\'", "stderr")) +check(qgrep("adding foo to workspace manifest", "stderr")) + +check(mtn("automate", "inventory"), 0, true, true) +check(qgrep("skipping invalid path '\\\\'", "stderr")) +check(qgrep('path "foo"', "stdout")) + ============================================================ --- NEWS 624126fa333f962c6ce80684adf755a00552b90a +++ NEWS 629cedfc5e6164fc8ea78616061d4712d557ce2a @@ -24,6 +24,9 @@ Bugs fixed + - Monotone now sanely skips paths with invalid characters + it encounters during 'add' or 'automate inventory'. + Internal Tue May 12 20:44:00 UTC 2009 ============================================================ --- file_io.cc 34e9c1581a7c336b0406c2601ac7cee5012723c7 +++ file_io.cc 1c79107b3af55f17b13b5dae75d1e5dc3448e59f @@ -234,11 +234,19 @@ namespace { fill_pc_vec(vector & v) : v(v) { v.clear(); } - // FIXME BUG: this treats 's' as being already utf8, but it is actually - // in the external character set. Also, will I() out on invalid - // pathnames, when it should N() or perhaps W() and skip. + // FIXME BUG: this treats 's' as being already utf8, + // but it is actually in the external character set. virtual void consume(char const * s) - { v.push_back(path_component(s)); } + { + try + { + v.push_back(path_component(s)); + } + catch (...) + { + W(F("skipping invalid path '%s'") % s); + } + } private: vector & v; @@ -249,8 +257,14 @@ namespace file_deleter(any_path const & p) : parent(p) {} virtual void consume(char const * f) { - // FIXME: same bug as above. - do_remove((parent / path_component(f)).as_external()); + try + { + do_remove((parent / path_component(f)).as_external()); + } + catch (...) + { + W(F("skipping invalid path '%s'") % f); + } } private: any_path const & parent;