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

Cannot save URI input node with invalid URI in it. #3495

Closed
Psychpsyo opened this issue Dec 28, 2021 · 1 comment
Closed

Cannot save URI input node with invalid URI in it. #3495

Psychpsyo opened this issue Dec 28, 2021 · 1 comment
Labels
Bug Something isn't working

Comments

@Psychpsyo
Copy link
Contributor

Describe the bug?

You can't save a URI input node if it has an invalid URI typed into it. (or anything that contains one)

Relevant issues

Didn't find any.

To Reproduce

  1. Type something like "abc" into a URI input node.
  2. Save it to your inventory.
  3. Observe that there is nothing in your inventory.

Expected behavior

The item should be saved to my inventory.

Log Files

No response

Screenshots

No response

How often does it happen?

Always

Does the bug persist after restarting Neos?

Yes

Neos Version Number

Beta 2021.11.10.1265

What Platforms does this occur on?

Windows

Link to Reproduction Item/World

I literally cannot provide this.

Did this work before?

I Don't Know

If it worked before, on which build?

No response

Additional context

No response

Reporters

Cameron#7818
KodeyTheNeko#1284

@Psychpsyo Psychpsyo added the Bug Something isn't working label Dec 28, 2021
@RobertBaruch
Copy link

RobertBaruch commented Dec 31, 2021

Stack trace in the logs when attempting to save a UriInput node with an invalid node:

System.AggregateException: One or more errors occurred. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at BaseX.DataTreeValue.ExtractURL () [0x00036] in <2cab77e73b74412faa09a9eb8498c7b9>:0 
  at BaseX.DataTreeValue.Extract[T] () [0x000b1] in <2cab77e73b74412faa09a9eb8498c7b9>:0 
  at FrooxEngine.DataTreeAssetProcessor+<Process>d__1.MoveNext () [0x000e5] in <c15eff494aa74d1a8369da64f3d2fe2a>:0

The problem is that UriInput::ParseValue treats its contents as a relative or absolute URI, while DataTreeValue attempts to create a URI from the contents and checks that it is a valid URI. These two methods are not compatible.

abc is a relative URI, and will not parse as a valid URI.

Solution 1: Change DataTreeValue::ExtractURL to construct a Uri in the same way as UriInput. This allows both relative and aboluste URIs to be serialized : return new Uri(value.Substring(1), UriKind.RelativeOrAbsolute); This may also require that TryExtractURL also be updated to accept relative URIs.

Solution 2: Do not accept relative URIs in UriInput. This means existing LogiX that relies on this behavior may break.

Solution 3: Use the same code as Cast_string_to_Uri does: if the text cannot initially be converted to a Uri using UriKind.Absolute, prepend http:// and try again. This would result in http://abc which is a valid Uri. Also, see the proposed Parse Uri node.

@Psychpsyo Psychpsyo closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants