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

bug: empty screen when URI is malformed #29479

Closed
3 tasks done
legendar opened this issue May 9, 2024 · 3 comments · Fixed by #29486
Closed
3 tasks done

bug: empty screen when URI is malformed #29479

legendar opened this issue May 9, 2024 · 3 comments · Fixed by #29486
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@legendar
Copy link

legendar commented May 9, 2024

Prerequisites

Ionic Framework Version

v7.x, v8.x

Current Behavior

When the URI is malformed, Ionic throws the "URI malformed" error, resulting in an empty screen being rendered. We want to handle this error using a React error boundary and render our standard error message instead. The issue arises when Ionic attempts to get configuration from the URL: https://github.com/ionic-team/ionic-framework/blob/main/core/src/global/ionic-global.ts#L43.

Additionaly, the second issue is: How can we disable this behavior, as we don't want to allow reconfiguration of our app from the URL in production?"

Expected Behavior

When the URI is malformed, Ionic should not drop an error. Instead, it should provide a way to catch this error or ignore it.

Steps to Reproduce

  1. Open any Ionic app in web browser
  2. Add the query param ?test=%. E.g. https://www.pandaexpress.com/location?test=%
  3. If your web server doesn't handle malformed URIs, you'll encounter a white screen in production mode.

Note that in development mode, you're more likely to see the standard error message from Vite.

Code Reproduction URL

https://www.pandaexpress.com/location?test=%

Ionic Info

Ionic:

Ionic CLI : 7.2.0
Ionic Framework : @ionic/react 7.5.8

Capacitor:

Capacitor CLI : 5.6.0
@capacitor/android : not installed
@capacitor/core : 5.6.0
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run (update available: 2.0.1) : 2.0.0

System:

NodeJS : v18.15.0
npm : 9.5.0
OS : Linux 5.15

Additional Information

No response

@sean-perkins
Copy link
Contributor

Hello @legendar thanks for opening up this issue.

I can confirm the issue with the malformed URI. Ionic Framework should not be causing an uncaught exception when decoding the URI. We can handle this exception and fallback the config object in these scenarios.

We want to handle this error using a React error boundary and render our standard error message instead.

This should be a concern of your application layer. When the location changes, attempt to decode the query parameters and catch any invalid cases that occur to handle in your React error boundaries.

How can we disable this behavior, as we don't want to allow reconfiguration of our app from the URL in production?

There is currently no way to opt-out of this behavior.

@sean-perkins sean-perkins added package: core @ionic/core package type: bug a confirmed bug report labels May 9, 2024
@ionitron-bot ionitron-bot bot removed the triage label May 9, 2024
@legendar
Copy link
Author

There is currently no way to opt-out of this behavior.

I see this in the code. However, what I mean is that we want to have a way to disable this behavior. Should I create a separate ticket for it?

@sean-perkins
Copy link
Contributor

@legendar yes, I would create a feature request around that specific API request to customize (opt-out) of that behavior. New APIs will be in a minor, but the malformed URI we can address in a patch.

github-merge-queue bot pushed a commit that referenced this issue May 15, 2024
Issue number: resolves #29479

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

If an application includes a malformed URI, an Ionic Framework can
"crash" due to an uncaught exception in parsing the URI for the Ionic
config.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Handle the malformed URI fallback if the config cannot be determined
- Added unit tests for this case

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants