Fix #19384 - varbinary equal search by faissaloux · Pull Request #19523 · phpmyadmin/phpmyadmin · GitHub
Skip to content

Fix #19384 - varbinary equal search#19523

Draft
faissaloux wants to merge 6 commits intophpmyadmin:QA_5_2from
faissaloux:fix-varbinary-equal-search
Draft

Fix #19384 - varbinary equal search#19523
faissaloux wants to merge 6 commits intophpmyadmin:QA_5_2from
faissaloux:fix-varbinary-equal-search

Conversation

@faissaloux
Copy link
Copy Markdown
Contributor

@faissaloux faissaloux commented Jan 15, 2025

Fixes #19384

While I was investigating this issue, I have found that all ops does not work with varbinary as it should.

In this PR I have fixed the equal op with varbinary field as it's the one reported now, other ops should be fixed on other PRs.

In case the value starts with 0x

image

In case the value is a simple string

image

martin762 and others added 5 commits June 19, 2024 18:53
The PR will modify the 'GetCookieName' functtion by hard coding the prefix ' __Secure-' to each cookie name when 'isHttps()' is true, Apparently the prefix will be recognise
d and enforced by most browsers (ignored by the older ones).Update Config.php

The raison d'aitre for this PR is contained in my issue # 18608.

This PR will replace the line 953, part of the GetCookieName function :
return $cookieName . ( $this->isHttps ? '_https' : '' );

with the amended line:
return ( $this->isHttps() ? '__Secure-' : '’ ) . $cookieName . ( $this->isHttps() ? '_https' : ‘’ );

Signed-off-by: martin762 <martin762green@btinternet.com>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: faissaloux <fwahabali@gmail.com>
Signed-off-by: faissaloux <fwahabali@gmail.com>
Comment thread libraries/classes/Table/Search.php Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should it not be in the line above preg_match('@char|binary|blob|text|set|date|time|year|uuid@i', $types) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah you are right! I didn't see that line, I'll check it tonight.

@kamil-tekiela
Copy link
Copy Markdown
Contributor

But that breaks the current behaviour. What if I really do want to search for a string like I can do with all other types?

@faissaloux
Copy link
Copy Markdown
Contributor Author

But that breaks the current behaviour. What if I really do want to search for a string like I can do with all other types?

Do you mean you need to search for a sting on a varbinary field?

@kamil-tekiela
Copy link
Copy Markdown
Contributor

But that breaks the current behaviour. What if I really do want to search for a string like I can do with all other types?

Do you mean you need to search for a sting on a varbinary field?

Yes, that should be possible by default.

@faissaloux
Copy link
Copy Markdown
Contributor Author

But that breaks the current behaviour. What if I really do want to search for a string like I can do with all other types?

Do you mean you need to search for a sting on a varbinary field?

Yes, that should be possible by default.

Isn't this what = " operator is for?

  • = shouldn't add any quotes.
  • =" should add quotes.

Can you confirm this.

image

@kamil-tekiela
Copy link
Copy Markdown
Contributor

Isn't this what = " operator is for?

No, that's not what this is for. This option allows you to search for an empty string. Try it, you can't enter the value because the condition will always be an empty string.

@faissaloux
Copy link
Copy Markdown
Contributor Author

Isn't this what = " operator is for?

No, that's not what this is for. This option allows you to search for an empty string. Try it, you can't enter the value because the condition will always be an empty string.

Oh it's confusing, so this is another issue that I should fix later on. Noted!

Can you give me an example where you gonna need quotes on a binary field please.

@kamil-tekiela
Copy link
Copy Markdown
Contributor

kamil-tekiela commented Jan 15, 2025

Can you give me an example where you gonna need quotes on a binary field please.

I am not sure what you're asking but basically any text would need quotes.

SELECT * FROM t WHERE vbin = 'foo';

The varbinary and binary types are basically text storage. And as with any text, it needs to be quoted. See https://dev.mysql.com/doc/refman/8.4/en/binary-varbinary.html

@faissaloux
Copy link
Copy Markdown
Contributor Author

So I'll add the quotes only if the inserted value is a simple string like foo, if it's not (eg: 0xfoo) quotes should not be used.

@kamil-tekiela
Copy link
Copy Markdown
Contributor

Yeah, that could work but how will you know when it's a special value?

@faissaloux
Copy link
Copy Markdown
Contributor Author

Yeah, that could work but how will you know when it's a special value?

Yeah exactly that's what I'm thinking about, the only idea I have now is check if the string starts with 0x we don't add the quotes.

Signed-off-by: faissaloux <fwahabali@gmail.com>
@faissaloux faissaloux requested a review from williamdes January 15, 2025 23:02
if (
preg_match('@char|binary|blob|text|set|date|time|year|uuid@i', $types)
(
preg_match('@char|binary|blob|text|set|date|time|year|uuid@i', $types)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this new version of the check is confusing me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, sorry
why was the varbinary type not added to the list ?
is there a case where varbinary is different from binary and not used in the 0x form ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why was the varbinary type not added to the list ?

I didn't have to add it since there is binary (substring) that detects it.

is there a case where varbinary is different from binary and not used in the 0x form ?

As @kamil-tekiela said and I tested it yes, it can be stored as normal string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still don't know about this. What if I search for a string 0x? Then the search query will be broken and now you have another more serious bug. I'd rather either not change anything or create a separate option allowing the user to provide a self-quoted string/numerical value.

Copy link
Copy Markdown
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

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

Okay, thank you both for the review and work !

@williamdes williamdes added this to the 5.2.2 milestone Jan 17, 2025
@kamil-tekiela
Copy link
Copy Markdown
Contributor

@williamdes williamdes removed this from the 5.2.2 milestone Jan 17, 2025
@williamdes williamdes changed the title Fix varbinary equal search Fix #19384 - varbinary equal search Jan 17, 2025
@williamdes williamdes marked this pull request as draft January 17, 2025 22:47
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.

6 participants