Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/plugins/dbms/spanner/syntax.py
4907 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
from lib.core.convert import getOrds
9
from plugins.generic.syntax import Syntax as GenericSyntax
10
11
class Syntax(GenericSyntax):
12
@staticmethod
13
def escape(expression, quote=True):
14
"""
15
Note: Google Standard SQL (Spanner) natively supports converting integer arrays
16
to strings via CODE_POINTS_TO_STRING(). This is much cleaner and shorter
17
than chaining multiple CHR() functions with the || operator.
18
19
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CODE_POINTS_TO_STRING([97, 98, 99, 100, 101, 102, 103, 104]) FROM foobar"
20
True
21
"""
22
23
def escaper(value):
24
return "CODE_POINTS_TO_STRING([%s])" % ", ".join(str(_) for _ in getOrds(value))
25
26
return Syntax._escape(expression, quote, escaper)
27
28