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

Spaces in URL query parameters not parsing correctly #198

Closed
schlingding opened this issue Apr 29, 2019 · 4 comments
Closed

Spaces in URL query parameters not parsing correctly #198

schlingding opened this issue Apr 29, 2019 · 4 comments
Assignees

Comments

@schlingding
Copy link

When switching from KituraNet to Kitura-NIO URLs errors occur with spaces in query parameters.

A URL such as http://www.something.com/hi/there?parameter=Hi%20There will either throw an exception (SwiftMetrics):

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSURLComponents setPercentEncodedQuery:]: invalid characters in percentEncodedQuery'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff2bd8ccf9 __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff56921a17 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff2bd8cb2b +[NSException raise:format:] + 201
    3   libswiftFoundation.dylib            0x00007fff57dc3ba2 $s10Foundation13URLComponentsV19percentEncodedQuerySSSgvsTf4gn_n + 402
    4   libswiftFoundation.dylib            0x00007fff57d5a0c2 $s10Foundation13URLComponentsV19percentEncodedQuerySSSgvs + 18
    5   KituraNet                           0x000000010122285d $s9KituraNet17HTTPServerRequestC6urlURL10Foundation0F0Vvg + 5597
    6   KituraNet                           0x0000000101227141 $s9KituraNet17HTTPServerRequestCAA06ServerD0A2aDP6urlURL10Foundation0G0VvgTW + 17
    7   SwiftMetricsKitura                  0x0000000100a124c3 $s18SwiftMetricsKitura11HttpMonitor33_AF26E906DB1EA1A8FEA139730DBA0D88LLC7started7request8responsey0C3Net13ServerRequest_p_AH0R8Response_ptF + 307
    8   SwiftMetricsKitura                  0x0000000100a137b5 $s18SwiftMetricsKitura11HttpMonitor33_AF26E906DB1EA1A8FEA139730DBA0D88LLC0C3Net06ServerE0AaeFP7started7request8responseyAE0O7Request_p_AE0O8Response_ptFTW + 21
    9   KituraNet                           0x0000000101210fe5 $s9KituraNet18HTTPRequestHandlerC11channelRead7context4datay3NIO07ChannelD7ContextC_AG6NIOAnyVtFyycfU_ + 837
    10  KituraNet                           0x00000001012110fc $s9KituraNet18HTTPRequestHandlerC11channelRead7context4datay3NIO07ChannelD7ContextC_AG6NIOAnyVtFyycfU_TA + 12
    11  KituraNet                           0x00000001011fe11d $sIeg_IeyB_TR + 45
    12  libdispatch.dylib                   0x0000000101dd8e7c _dispatch_call_block_and_release + 12
    13  libdispatch.dylib                   0x0000000101dd9f1b _dispatch_client_callout + 8
    14  libdispatch.dylib                   0x0000000101deca06 _dispatch_root_queue_drain + 816
    15  libdispatch.dylib                   0x0000000101ded2da _dispatch_worker_thread2 + 125
    16  libsystem_pthread.dylib             0x0000000101e530b7 _pthread_wqthread + 583
    17  libsystem_pthread.dylib             0x0000000101e52e01 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

OR have a Router error without Swift Metrics:

[ERROR] [Router.swift:613 process(request:response:callback:)] request.parsedURLPath.path is nil. Failed to process request
@pushkarnk pushkarnk self-assigned this Apr 30, 2019
@pushkarnk
Copy link
Contributor

I have a possible hypothesis and fix for this problem. I want to test it with Kitura-CouchDB, SwiftMetrics and Kitura-Sample before creating a pull request here.

@pushkarnk
Copy link
Contributor

The use of URLComponents to build the URL in HTTPServerRequest.urlURL seems to be sending us into a spiral of problems. I'm planning to do away with URLComponents and fallback to building a URL string instead, something that we did in the past.

@pushkarnk
Copy link
Contributor

Submitted a pull request: #199

@djones6
Copy link
Contributor

djones6 commented Jun 7, 2019

Fix (#199) has been tagged in 2.1.1

@djones6 djones6 closed this as completed Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants