Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCL searchMeasureLibrary should encode spaces in the pattern #4336

Closed
jmarrec opened this issue May 31, 2021 · 0 comments · Fixed by #4337
Closed

BCL searchMeasureLibrary should encode spaces in the pattern #4336

jmarrec opened this issue May 31, 2021 · 0 comments · Fixed by #4337

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented May 31, 2021

Issue overview

If you search for a bcl measure using a space in the pattern, it crashes

terminate called after throwing an instance of 'web::uri_exception'
  what():  provided uri is invalid: /api/metasearch/test a space.xml?fq%5B%5D=bundle:nrel_measure&fq%5B%5D=tid:953&api_version=2.0
Process 30980 stopped

Current Behavior

It crashes

Expected Behavior

It should encode the space, like it does the + as %2B

bool RemoteBCL::startComponentLibraryMetaSearch(const std::string& searchTerm, const std::string& componentType, const std::string& filterType) {
// can't start another request until last one is done
if (m_httpResponse && !m_httpResponse->is_done()) {
return false;
}
m_lastMetaSearch.reset();
auto client = getClient(remoteUrl(), m_timeOutSeconds);
web::uri_builder builder(U("/api/metasearch/"));
auto query = searchTerm.empty() ? "*" : searchTerm;
query = std::regex_replace(query, std::regex("\\+"), "%2B");
builder.append_path(to_string_t(query + ".xml"));
builder.append_query(U("fq[]"), to_string_t("bundle:" + filterType));

Steps to Reproduce

Possible Solution

encode

Details

backtrace

(lldb) bt
* thread #1, name = 'OpenStudioApp', stop reason = signal SIGABRT
  * frame #0: 0x00007fffe8d0e18b libc.so.6`raise + 203
    frame #1: 0x00007fffe8ced859 libc.so.6`abort + 299
    frame #2: 0x00007fffe90c5a31 libstdc++.so.6`___lldb_unnamed_symbol33$$libstdc++.so.6 + 93
    frame #3: 0x00007fffe90d15dc libstdc++.so.6`___lldb_unnamed_symbol443$$libstdc++.so.6 + 12
    frame #4: 0x00007fffe90d1647 libstdc++.so.6`std::terminate() + 23
    frame #5: 0x00007fffe90d18e9 libstdc++.so.6`__cxa_throw + 73
    frame #6: 0x00007ffff415ce96 libopenstudiolib.so`web::uri::uri(web::details::uri_components const&) (.cold) + 236
    frame #7: 0x00007ffff607ddae libopenstudiolib.so`web::uri_builder::to_uri() const + 14
    frame #8: 0x00007ffff607e91f libopenstudiolib.so`web::uri_builder::to_string[abi:cxx11]() const + 47
    frame #9: 0x00007ffff41f1b08 libopenstudiolib.so`openstudio::RemoteBCL::startComponentLibraryMetaSearch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 1208
    frame #10: 0x00007ffff41f1dd1 libopenstudiolib.so`openstudio::RemoteBCL::metaSearchComponentLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const + 49
    frame #11: 0x00007ffff41f36c6 libopenstudiolib.so`openstudio::RemoteBCL::searchMeasureLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int) const + 102
    frame #12: 0x0000555556557707 OpenStudioApp`openstudio::BuildingComponentDialogCentralWidget::setTid(this=0x0000555557ada3c0, filterType="measures", tid=953, pageIdx=0, title=b'""', searchString=b'""') at BuildingComponentDialogCentralWidget.cpp:202:47
    frame #13: 0x0000555556554a92 OpenStudioApp`openstudio::BuildingComponentDialog::requestComponents(this=0x00007fffd8009ce0, filterType="measures", tids=953, pageIdx=0, searchString=b'""') at BuildingComponentDialog.cpp:278:26
    frame #14: 0x0000555556554c4e OpenStudioApp`openstudio::BuildingComponentDialog::on_searchButton(this=0x00007fffd8009ce0) at BuildingComponentDialog.cpp:297:20
    frame #15: 0x0000555556555fdf OpenStudioApp`QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (openstudio::BuildingComponentDialog::*)()>::call(f=48 4b 55 56 55 55 00 00 00 00 00 00 00 00 00 00, o=0x00007fffd8009ce0, arg=0x00007fffffffbea0)(), openstudio::BuildingComponentDialog*, void**) at qobjectdefs_impl.h:152:20
    frame #16: 0x0000555556555e3a OpenStudioApp`void QtPrivate::FunctionPointer<void (openstudio::BuildingComponentDialog::*)()>::call<QtPrivate::List<>, void>(f=48 4b 55 56 55 55 00 00 00 00 00 00 00 00 00 00, o=0x00007fffd8009ce0, arg=0x00007fffffffbea0)(), openstudio::BuildingComponentDialog*, void**) at qobjectdefs_impl.h:185:95
    frame #17: 0x00005555565559c9 OpenStudioApp`QtPrivate::QSlotObject<void (openstudio::BuildingComponentDialog::*)(), QtPrivate::List<>, void>::impl(which=1, this_=0x0000555557a3e850, r=0x00007fffd8009ce0, a=0x00007fffffffbea0, ret=0x0000000000000000) at qobjectdefs_impl.h:418:49

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version):
  • Version of OpenStudio (if using an intermediate build, include SHA):

Context

Transfered from openstudiocoalition/OpenStudioApplication#274 (comment)

@jmarrec jmarrec added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label May 31, 2021
@jmarrec jmarrec added component - Utilities Other severity - Normal Bug and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Jun 1, 2021
@jmarrec jmarrec self-assigned this Jun 1, 2021
jmarrec added a commit that referenced this issue Jun 1, 2021
tijcolem added a commit that referenced this issue Jun 3, 2021
Fix #4336 - Encode searchTerm in BCL (including spaces, not only "+" signs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant