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

Ensure that new line chars don't break Panache projection #29851

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Dec 14, 2022

Fixes: #29838

Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

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

lgtm

@geoand geoand added triage/waiting-for-ci Ready to merge when CI successfully finishes triage/backport-2.13 triage/backport? labels Dec 14, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 14, 2022

Failing Jobs - Building 756568a

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
✔️ JVM Tests - JDK 17
JVM Tests - JDK 17 MacOS M1 Set up runner ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 18

@geoand geoand merged commit e151807 into quarkusio:main Dec 14, 2022
@quarkus-bot quarkus-bot bot added this to the 2.16 - main milestone Dec 14, 2022
@quarkus-bot quarkus-bot bot added kind/bugfix and removed triage/waiting-for-ci Ready to merge when CI successfully finishes labels Dec 14, 2022
@@ -54,6 +54,8 @@ public void close() {

private Map<String, Map<String, Object>> filters;

private final String lineSeparator = System.getProperty("line.separator");
Copy link
Member

Choose a reason for hiding this comment

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

Is it really a good idea to use this? From the original issue, it seems that the new lines are provided by the source code and this won't necessarily match the system line separator? Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Do we know how Java's multi line strings behave?

Copy link
Contributor

Choose a reason for hiding this comment

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

This may be difficult to cover all use cases as someone may add “\n” , “\r”, or “\r\n” anywhere and request can comes from a config file.
Maybe it should be done for the 3 possible line separator, or using a "\R": https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#lineending

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 think that makes sense. Do you want to follow up with that @loicmathieu ?

Copy link
Member

@gsmet gsmet Dec 14, 2022

Choose a reason for hiding this comment

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

Well, given what we already do, I would just replace both \r and \n. If the user is using \n in strings embedded in the query, things are already broken so it won't make things worse to handle both.

Copy link
Contributor

@Felk Felk Dec 14, 2022

Choose a reason for hiding this comment

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

Thinking of weird contrived edge cases, what if someone writes a query like this...?

select o.id, 'came from Sydney' as comment from Orders o

(it contains ' from ', though not as a sql keyword)

Copy link
Contributor

Choose a reason for hiding this comment

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

@gsmet i'll provide a PR to direclty handle \n and \r it will be better.
@Felk this kind of edge case cannot be handled as we didn't parse the query. For this, I strongly suggest to not use Panache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StringIndexOutOfBoundsException in panache when using project and a linebreak before FROM
4 participants