Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-19-2010, 09:25 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
string.escape()

string.escape() places a backslash in front of quotation marks. SQLite doesn't require quotation marks to be escaped at all, so ideally it should be fixed, and another function should be added (if needed) for MySQL support (accounts database?).
__________________
Reply With Quote
  #2  
Old 01-20-2010, 02:13 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
... Wha? That's what escaping is, and the point of escaping is to prevent SQL injections, not because SQLite can't handle quotation marks.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #3  
Old 01-20-2010, 02:23 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by LoneAngelIbesu View Post
... Wha? That's what escaping is, and the point of escaping is to prevent SQL injections, not because SQLite can't handle quotation marks.
I'm tempted to say the same thing to you: wha?

If you feed SQLite as string such as:
PHP Code:
test "foo" bar 
it will enter perfectly fine:

PHP Code:
INSERT INTO table (columnVALUES ('test "foo" bar'
str.escape() places backslashes in front of quotations. Basically, it does:
PHP Code:
INSERT INTO table (columnVALUES ('test \"foo\" bar'
It's literally inserted into SQLite as:

PHP Code:
test \"foo\" bar 

Unlike single quotations, quotation marks don't need to be escaped, and escaping them only makes strings enter incorrectly.

I think maybe you thought I was referring to single quotes instead of quotation marks in my post, sorry; could've been more clear about that.
__________________
Reply With Quote
  #4  
Old 01-20-2010, 04:51 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by cbk1994 View Post
Unlike single quotations, quotation marks don't need to be escaped, and escaping them only makes strings enter incorrectly.
Oh, I see what you're saying, now. Yes, that probably does need to be fixed. My second nature is to still be weary about quotations when it comes to user-submitted SQL entries, though. Even if they're double-quotations.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #5  
Old 02-21-2010, 03:41 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
bump
__________________
Reply With Quote
  #6  
Old 02-21-2010, 06:29 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
What makes you think escape() is for sqlite?
Reply With Quote
  #7  
Old 02-21-2010, 06:47 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Loriel View Post
What makes you think escape() is for sqlite?
Stefan has said to use it for SQLite and uses it himself. He has also made changes to it for SQLite.
__________________
Reply With Quote
  #8  
Old 02-21-2010, 09:28 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Well that is rather ridiculous considering sql has different escaping rules than everything else

my apologies, but, uh, just do not do it anyway.
Reply With Quote
  #9  
Old 02-21-2010, 10:56 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Loriel View Post
Well that is rather ridiculous considering sql has different escaping rules than everything else

my apologies, but, uh, just do not do it anyway.
Yea, that is my issue. I remember suggesting a separate sqlescape() function since the rules are different for that, and Stefan just changed the default escape and messed it all up.

My reaction:
__________________
Reply With Quote
  #10  
Old 03-03-2010, 07:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
This is still a problem after the NPC-server update
__________________
Reply With Quote
  #11  
Old 03-03-2010, 05:06 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Inverness View Post
Yea, that is my issue. I remember suggesting a separate sqlescape() function since the rules are different for that, and Stefan just changed the default escape and messed it all up.
The escape command has already been existing since 2007 and used for mysql queries since 2007.
Reply With Quote
  #12  
Old 03-03-2010, 08:56 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stefan View Post
The escape command has already been existing since 2007 and used for mysql queries since 2007.
" (quotation marks) don't need to be escaped in MySQL either. Can you please fix it?
__________________
Reply With Quote
  #13  
Old 03-03-2010, 11:30 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
" (quotation marks) don't need to be escaped in MySQL either. Can you please fix it?
Double quotes are used in the SQL syntax as identifers (like backticks: `). MySQL doesn't follow that specification if the ANSI_QUOTES SQL mode isn't enabled. Instead, MySQL uses them as string quotes in that case (like single quotes: ').

So really, the proper way to go about this is always use single quotes and only escape single quotes (go ahead and make your own function). But escaping both leaves no room for injection, only room for extra backslashes, which can be fixed.
Reply With Quote
  #14  
Old 03-04-2010, 06:03 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
The escape command has already been existing since 2007 and used for mysql queries since 2007.
The whole point of what I said is that normal escape rules aren't like those for SQLite, so there needs to be a separate function.
__________________
Reply With Quote
  #15  
Old 04-02-2010, 03:17 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by WhiteDragon View Post
... only room for extra backslashes, which can be fixed.
Bumping this, and asking for stripslashes() function.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #16  
Old 04-02-2010, 04:19 AM
benpoke103 benpoke103 is offline
Zvarri!
benpoke103's Avatar
Join Date: Jun 2002
Posts: 332
benpoke103 will become famous soon enough
Quote:
Originally Posted by LoneAngelIbesu View Post
Bumping this, and asking for stripslashes() function.
^ This.
__________________
Need support? Here's how to reach me.

Forum PM (Preferred)
#graaldt @ Freenode
Reply With Quote
  #17  
Old 04-05-2010, 06:13 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Modified Dusty's replacetext() function into a simple stripslashes() function. It wakes into account new lines (\n). I don't know if there's more to take into account, since I really only needed to script something so that it doesn't ruin new lines.
PHP Code:
function stripslashes(txt,a,b) { 
  
// a=\ b=""
  
if (txt.pos(a)<0) return txt
  
temp.txtpos txt.positions(a); 
  
temp.newtxt txt.substring(0,txtpos[0]); 
  for (
temp.i=0;i<txtpos.size();i++) { 
    if(
txt.substring(txtpos[i]+1,1) == "n") {
      
newtxt @= "\\n";
      
newtxt @= txt.substring(txtpos[i]+a.length()+1,txt.substring(txtpos[i]+a.length()+1).pos(a));
    }
    else {
      
newtxt @= b
      
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a)); 
    }
  } 
  return 
newtxt

Use: stripslashes(mystring, "\\", "");
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #18  
Old 06-27-2010, 03:43 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
This is absolutely ridiculous. This should have been fixed six months ago. Why hasn't it been done?
__________________
Reply With Quote
  #19  
Old 06-27-2010, 05:53 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
This is absolutely ridiculous. This should have been fixed six months ago. Why hasn't it been done?
It's all your fault, you failed to bump this topic.
Reply With Quote
  #20  
Old 08-22-2010, 03:30 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by cbk1994 View Post
This is absolutely ridiculous. This should have been fixed six months ago. Why hasn't it been done?
See quote. This is rather important.
__________________
Reply With Quote
  #21  
Old 06-06-2011, 06:39 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
16 months later...
__________________
Reply With Quote
  #22  
Old 06-12-2011, 08:16 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Ok will add a new function escapestring2(string).
If that function is tested and fine then we can also integrate it similar to escapestring(string) which is additionally mapped to string.escape().
Reply With Quote
  #23  
Old 06-14-2011, 02:39 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stefan View Post
Ok will add a new function escapestring2(string).
If that function is tested and fine then we can also integrate it similar to escapestring(string) which is additionally mapped to string.escape().
Sounds good, thanks Stefan .
__________________
Reply With Quote
  #24  
Old 07-23-2011, 02:27 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stefan View Post
Ok will add a new function escapestring2(string).
If that function is tested and fine then we can also integrate it similar to escapestring(string) which is additionally mapped to string.escape().
I've tested escapestring2 and it is working with all ASCII characters above 29. Thanks Stefan .
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.