seb-mac icon indicating copy to clipboard operation
seb-mac copied to clipboard

SEBMAC-610 Fix Query Parameter feature in iOS version

Open danschlet opened this issue 1 year ago • 15 comments

Describe the bug The Query Parameter feature isn't working in SEB for iOS.

To Reproduce Steps to reproduce the behavior:

  1. Open this link in Safari: sebs://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb??id=6
  2. SEB will be started and a Moodle login should be requested (use seb1/demo)
  3. If Moodle displays a quiz, it works, if an error is displayed, the Query Parameter isn't working.

Expected behavior The URL in the config file with appended Query Parameter from the invoked sebs link should be loaded by SEB.

Version Information Please complete the following information:

  • OS: iOS/iPadOS 17.4.1 (happens with all iOS versions)
  • SEB Version SEB 3.3.3

danschlet avatar May 10 '24 14:05 danschlet

Should be fixed in SEB 3.4. Please test if it works for you.

danschlet avatar Dec 10 '24 13:12 danschlet

Problem Persists in 3.5 "unsupported url" error is thrown if a second "?" is added. sebs://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb?aid=1&bid=2?cid=3&eid=4

Link opened from running SEB

2025/05/06 14:50:12:940  Trying to reload after -[SEBBrowserWindow sebWebViewDidFailLoadWithError:]_block_invoke: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44" UserInfo={networkTaskMetricsPrivacyStance=Unknown, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <68E8C45C-17A9-4FA9-95D7-FFC46D017B2C>.<29>, _NSU$

    "LocalDataTask <68E8C45C-17A9-4FA9-95D7-FFC46D017B2C>.<29>"

), NSLocalizedDescription=unsupported URL

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44, _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x7fbc76f47950>, networkTaskDescription=LocalDataTask <68E8C45C-17A9-4FA9-95D7-FFC46D017$

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44

2025/05/06 14:50:12:943  webView decidePolicyFor navigationAction: Target frame nil, URL: nil

2025/05/06 14:50:12:947  -[SEBAbstractWebView sebWebViewDidFailLoadWithError:]: Load Error: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={networkTaskMetricsPrivacyStance=Unknown, _NSURLErrorFailingURLSessionTaskErr$

    "LocalDataTask <677056CA-7F27-4072-9ACE-6ECD5044ABF2>.<30>"

), NSLocalizedDescription=unsupported URL, _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x7fbc74c42590>, networkTaskDescription=LocalDataTask <677056CA-7F27-4072-9ACE-6ECD5044ABF2>.<30>, NSErrorFailingURLStringKey=s$

2025/05/06 14:50:12:948  -[SEBBrowserWindow sebWebViewDidFailLoadWithError:]: Load error with localized description: unsupported URL

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44

2025/05/06 14:50:12:948  Attempting to close About Window <AboutWindowController: 0x7fbc78308160>

2025/05/06 14:50:12:957  Adding modal alert window <_NSAlertPanel: 0x7fbc76829970>

2025/05/06 14:50:12:983  BrowserWindow <SEBBrowserWindow: 0x7fbc78329ee0> did resign key

2025/05/06 14:50:12:983  Current key window: <_NSAlertPanel: 0x7fbc76829970> with title

2025/05/06 14:50:12:983  Current key window is modal panel: <_NSAlertPanel: 0x7fbc76829970>

2025/05/06 14:50:18:799  BrowserWindow <SEBBrowserWindow: 0x7fbc78329ee0> did become key   

2025/05/06 14:50:18:802  All modal alert windows (

    "<_NSAlertPanel: 0x7fbc76829970>"

)

2025/05/06 14:50:18:802  Removing modal alert window <_NSAlertPanel: 0x7fbc76829970>

2025/05/06 14:50:18:802  All modal alert windows after removing: (

)

2025/05/06 14:50:18:802  User didn't select to reload after -[SEBBrowserWindow sebWebViewDidFailLoadWithError:]_block_invoke: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44" UserInfo={networkTaskMetricsPrivacyStance=Unknown, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <677056CA-7F27-4072-9ACE-6ECD5044ABF2>.<30>, _NSU$

    "LocalDataTask <677056CA-7F27-4072-9ACE-6ECD5044ABF2>.<30>"

), NSLocalizedDescription=unsupported URL

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44, _WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x7fbc74c42590>, networkTaskDescription=LocalDataTask <677056CA-7F27-4072-9ACE-6ECD5044A$

seb://10.12.0.5:8000/mod/tureview/configureseb.php?cmid=55&attempt=44?attempt=44

2025/05/06 14:50:18:802  -[SEBBrowserController openingConfigURLFailed]

2025/05/06 14:50:18:802  -[SEBOSXBrowserController openingConfigURLRoleBack]: SEB is starting up and opening a config link wasn't successfull, SEB will be terminated!

2025/05/06 14:50:18:802  -[SEBController requestedExit:]

2025/05/06 14:50:18:802  -[SEBController requestedExit:]_block_invoke Conditionally closed (optional) proctoring

2025/05/06 14:50:18:802  -[SEBController requestedExit:]_block_invoke_2 Conditionally closed (optional) SEB Server connection (restart: 0)

2025/05/06 14:50:18:802  -[SEBController exitSEB]

28Smiles avatar May 06 '25 11:05 28Smiles

Well it works with the original, correct query string link (link SEB Moodle Demo Exam invoked with additional query string (Debug, no kiosk mode) sebs://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb??id=6) on the page https://demo.safeexambrowser.org/exams/).

The link sebs://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb?aid=1&bid=2?cid=3&eid=4 which I assume you used as an example doesn't make sense anyways. SEB uses the URL up to the second '?' as the URL to download an SEB config file. If that config file has the setting startURLAppendQueryParameter = true, it will use the partial string following the second '?' and attach that as a query to the startURL from those settings.

If you are sure you understand how the feature is supposed to work then please send us a complete testing link/config so we can debug it.

danschlet avatar May 06 '25 20:05 danschlet

Since it works flawlessly under Windows, I would certainly assume that there is an issue. But I will still investigate further and provide you with an example soon

28Smiles avatar May 06 '25 20:05 28Smiles

The CEF browser engine used by SEB for Windows is more forgiving regarding non-compliant URLs than the WebKit engine used by the macOS version. But we can analyze that further with a full testing example.

danschlet avatar May 06 '25 21:05 danschlet

For me opening Moodle in seb and clicking on the provided link resulted in the same error as in my „working sample“ with an SebConfig behind the link, since the error occurred during parsing of the link, that’s why i provided

28Smiles avatar May 06 '25 21:05 28Smiles

Which link, this one sebs://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb?aid=1&bid=2?cid=3&eid=4 ?

As mentioned, this is a wrong link which doesn't make sense. SEB will attempt to download a .seb file from the URL https://safeexambrowser.org/testing/DemoExamMoodleQueryDebug.seb?aid=1&bid=2. DemoExamMoodleQueryDebug.seb is not a php script for which the query ?aid=1&bid=2 might make sense, so SEB will react with an error.

danschlet avatar May 06 '25 21:05 danschlet

Since I am not at work anymore I have no sample at hand, but i can assure you it produces the same error regardless of whether there is a valid seb file or anything behind the link, the browser will throw an error beforehand. I tested both ways

28Smiles avatar May 06 '25 21:05 28Smiles

Yes, we need a working sample, then we can continue.

I just know that the testing link on the SEB website still works, so for now I consider the feature to work correctly ;-).

danschlet avatar May 06 '25 21:05 danschlet

I produced a minimal sample, different error, but same bug: https://github.com/28Smiles/sebquerytest

NOTE: Error is thrown serverside but wrong behavior is CLIENTSIDE

For good measure compare the urls:

WINDOWS: Image

IOS: Image

MACOS: Image

28Smiles avatar May 07 '25 09:05 28Smiles

I still don't understand what the problem should be and I don't have time to install some docker stuff and do individual tests.

Only Gold Contributors or higher of the SEB Alliance get personal consulting by SEB developers.

If you cannot phrase a compliant bug report, we cannot help you.

danschlet avatar May 07 '25 09:05 danschlet

Please take a close look at the correspondent urls, the seb-mac urls contain 2 questionmarks

28Smiles avatar May 07 '25 09:05 28Smiles

Since I dont work in the MacOS IOS environment, i dont know exactly, but i would guess, these lines https://github.com/SafeExamBrowser/seb-mac/blob/093c9bc7b57621b1292a4e837e46f6433fe711d2/Classes/BrowserComponents/SEBOSXBrowserController.m#L284 https://github.com/SafeExamBrowser/seb-mac/blob/093c9bc7b57621b1292a4e837e46f6433fe711d2/SEB/Classes/BrowserComponents/SEBBrowserTabViewController.m#L826 Does not Handle the case that the urlString already contains query parameters, and therefore only appends the questionmark, therefore in seb-mac, any url containing a queryparameter in the starturl after the first question mark will result in an invalid url. Since i now know the exact error, i am able to bypass it by just removing all queryparams from a start url.

28Smiles avatar May 07 '25 10:05 28Smiles

Using ChatGPT with some changes (since i dont know the programming language at all this seems to be the solution), maybe someone with an ios background will someday find this issue and implement a solution:

// Check if startURL already contains a '?' (query separator)
BOOL hasQuery = [startURL containsString:@"?"];
if (hasQuery) {
    // Append the query parameters to existing startURL
    urlString = [NSString stringWithFormat:@"%@&%@", startURL, queryString];
} else {
    // Append the query string to existing startURL
    urlString = [NSString stringWithFormat:@"%@?%@", startURL, queryString];
}

28Smiles avatar May 07 '25 10:05 28Smiles

Ok, now I understand. When I specified this feature (it was first available in the iOS/macOS versions of SEB), it was not supposed to support the case that the startURL itself would contain a query. When startURLAppendQueryParameter = true, the complete query is supposed to come from the invoking seb(s) link.

When the feature was implemented in the Windows version, the specification seems to have been extended to handle the case startURL already contains a query. This seems like a useful extension of the feature and of course prevents that an invalid URL with two query '?' is constructed.

I will add this case to the backlog. Maybe it can be implemented for SEB 3.6 this fall.

Until then you would need to specify the full query in the invoking seb(s) link, then it should work both with macOS/iOS and Windows.

danschlet avatar May 07 '25 11:05 danschlet