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

Desktop: Resolves #11575: Remove "URI malformed" alert #11576

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

wh201906
Copy link
Contributor

@wh201906 wh201906 commented Jan 4, 2025

Resolves #11575

The "URI malformed" alert is triggered here.

const link = decodeURI(encodedLink);

The "malformed" link is less likely to be a Resource URI, so we can leave it as it is. I add the catch statement to prevent the alert dialog and log it as a warning.

@wh201906
Copy link
Contributor Author

wh201906 commented Jan 4, 2025

We can also log it with logger.info() rather than logger.warn(), For the "malformed" link, the content won't be changed and it doesn't affect the APP so no need to worry about it.

@laurent22
Copy link
Owner

Thanks for the pr. Is there not a built-in logger in importers with this.logger? (Sorry don't have the code in front of me)

@wh201906
Copy link
Contributor Author

wh201906 commented Jan 4, 2025

There isn't such a logger in InteropService_Importer_Md and InteropService_Importer_Base, so I added it.

@laurent22
Copy link
Owner

No that's fine, no need to add it in this case. But we have a test file - any chance you could add a test based on it?

@wh201906
Copy link
Contributor Author

wh201906 commented Jan 4, 2025

No that's fine, no need to add it in this case.

@laurent22 So I don't even need to log the URI malformed alert in the log, right?

But we have a test file - any chance you could add a test based on it?

I've added it in commit d577ea9. The new test fails on the current dev branch (commit 2b43a9a), which is expected.
The new test is based on should not fail to import file that contains a link to a file that does not exist and should not import resources from file:// links

@wh201906 wh201906 changed the title Desktop: Resolves #11575: Move "URI malformed" alert to the log Desktop: Resolves #11575: Remove "URI malformed" alert Jan 6, 2025
@wh201906
Copy link
Contributor Author

wh201906 commented Jan 6, 2025

@laurent22 I've removed the logger.


if (isDataUrl(link)) {
// Just leave it as it is. We could potentially import
// it as a resource but for now that's good enough.
continue;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why a continue also needs to be added here? It seems unrelated to the original bug since this is to deal with data URLs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it at Line 124 because I want to make the style consistent. The continue at Line 118 is for excluding any further processing to the malformed URLs. I think this also applies to the data URLs so I add a continue here.
The extra continue at Line 124 doesn't affect the existing logic because all the following processing is in the else {...} block. In fact, we can even remove the else statement here because the following statements in the for loop is skipped.
If you feel it's inappropriate to add continue at Line 124, I can also remove it.

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

Successfully merging this pull request may close these issues.

Fix uir malformed issue
2 participants