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

Always escape identifiers in the set(), setUpdateBatch(), and insertBatch() #5132

Merged

Conversation

ytetsuro
Copy link
Contributor

@ytetsuro ytetsuro commented Sep 25, 2021

Fixed a problem where identifiers were not escaped in the set, setUpdateBatch, and insertBatch methods.

Description

I decided that there was no case where the column name in the set clause did not need to be escaped, so I turned off the unescaping process.
The same goes for the table name when inserting.

see: #2487 (comment)

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from b8dfe29 to ef08b6f Compare September 25, 2021 21:54
@ytetsuro ytetsuro changed the title WIP Fixed the problem of not escaping column names in the set method. Fixed the problem of not escaping column names in the set method. Sep 25, 2021
@kenjis
Copy link
Member

kenjis commented Sep 25, 2021

You need to update the PHPdoc.

* @param bool|null $escape Whether to escape values and identifiers

And user guide, too.
https://codeigniter4.github.io/CodeIgniter4/database/query_builder.html#set

@kenjis kenjis added the database Issues or pull requests that affect the database layer label Sep 25, 2021
@ytetsuro ytetsuro changed the title Fixed the problem of not escaping column names in the set method. Fixed a problem where identifiers were not escaped in the set, setUpdateBatch, and insertBatch methods. Sep 26, 2021
@ytetsuro
Copy link
Contributor Author

ytetsuro commented Sep 26, 2021

@kenjis

You need to update the PHPdoc.
And user guide, too.

Thanks, response.
Fixed it.

Thanks to your pointers, I realized that I have a problem similar to this case with the setUpdateBatch and insertBatch identifiers.
Thank you very much.
I've fixed this as well and added a test.

@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from 6ae5657 to 1b05bb6 Compare September 26, 2021 02:49
@kenjis
Copy link
Member

kenjis commented Sep 26, 2021

@ytetsuro
Your commit message like the following means the opposite what you did.

fix: removed unnecessary escaping process in setUpdateBatch as well.

It should be like fix: always escape identifiers in setUpdateBatch()

@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from 1b05bb6 to 9ac8f50 Compare September 26, 2021 04:22
@ytetsuro
Copy link
Contributor Author

@kenjis

Your commit message like the following means the opposite what you did.

Thanks, response.

You are right.

Fixed it.💪

@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from 9ac8f50 to fc2b487 Compare September 26, 2021 04:23
@kenjis
Copy link
Member

kenjis commented Sep 26, 2021

@ytetsuro

The first commit:

fix: Because we have made escaping unnecessary in places where it is not necessary.

Sorry, I don't know what you are saying.

DeepL translation:

逃げることを必要としない場所では、逃げることを不要としたからです。

Google translation:

必要のない場所での脱出を不要にしたからです。

@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from fc2b487 to 4c67b69 Compare September 26, 2021 05:21
@ytetsuro
Copy link
Contributor Author

I don't know what you are saying.

Sorry.
Fixed it.💪

@kenjis
Copy link
Member

kenjis commented Sep 28, 2021

I didn't understand it before, but this change is necessary for the normal use case in Oracle.

The normal use case is when an identifier is quoted and lowercased, like "name".

In this case, if a user specify $escape to false, the identifiers will not be quoted, and Oracle will not find the identifier.
name is not equal to "name".

See https://seeq.atlassian.net/wiki/spaces/KB/pages/443088907/SQL+Column+Names+and+Case+Sensitivity
for Oracle identifier case sensitivity.

Copy link
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

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

Cancel the approval once.

@kenjis kenjis changed the title Fixed a problem where identifiers were not escaped in the set, setUpdateBatch, and insertBatch methods. Always escapae identifiers in the set(), setUpdateBatch(), and insertBatch() Sep 28, 2021
I decided that there was no case where the column name in the set clause did not need to be escaped, so I turned off the unescaping process.
@ytetsuro ytetsuro force-pushed the fix/lack_of_escape_for_set branch from 4c67b69 to 713ac6f Compare September 28, 2021 16:14
@ytetsuro
Copy link
Contributor Author

@kenjis

I'm sorry to have bothered you.
I've aligned the commit messages.

@paulbalandan paulbalandan changed the title Always escapae identifiers in the set(), setUpdateBatch(), and insertBatch() Always escape identifiers in the set(), setUpdateBatch(), and insertBatch() Sep 29, 2021
Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

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

Let us include this change in the user guide changelog.

@ytetsuro
Copy link
Contributor Author

@paulbalandan

I'm sorry.
I have no experience in writing changelog.

Please tell me.
Is the changelog to be updated using the following procedure?
Is it my CI4 repository to push the release branch?

https://github.com/codeigniter4/CodeIgniter4/blob/0f0c1d6514c0234f4d16bdca0e5e308a39168986/admin/RELEASE.md#codeigniter4

@paulbalandan
Copy link
Member

@ytetsuro
Copy link
Contributor Author

ytetsuro commented Oct 2, 2021

@paulbalandan

Thanks, response.

Fixed it.

@paulbalandan paulbalandan merged commit add6083 into codeigniter4:develop Oct 3, 2021
@paulbalandan
Copy link
Member

Thank you, @ytetsuro

@ytetsuro ytetsuro deleted the fix/lack_of_escape_for_set branch October 3, 2021 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Issues or pull requests that affect the database layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants