為防範安全漏洞,Looker 限制了 html 參數、自訂歡迎電子郵件、文字圖塊,以及圖表上方或下方顯示的圖塊附註中,可使用的 HTML 代碼、HTML 代碼屬性和 CSS 屬性。懸停資訊方塊附註遵循更嚴格的清理和高度限制。
Looker 會從轉譯的 HTML 中移除任何不支援的 HTML 元素。舉例來說,下列 HTML 含有不支援的 HTML 代碼:
<div class="pretty"><badtag></badtag></div>
Looker 會將其轉譯為:
<div class="pretty"></div>
另一個例子是,下列 HTML 含有不支援的 HTML 屬性:
<div class="pretty" badattr="uh-oh"></div>
Looker 會將其轉譯為:
<div class="pretty"></div>
HTML 清理功能預設為開啟,無法編輯。
懸停附註的限制
懸停附註會使用更嚴格的 HTML 許可清單和高度限制,不適用於顯示在圖表上方或下方的附註。這些限制適用於下列懸停附註:
- 資訊主頁圖塊附註,且「顯示位置」設為「滑鼠游標懸停在圖示上時」(或 LookML 資訊主頁元素含有
display: hover或note_display: hover)。 - KPI (單一值) 和單一值 (舊版) 圖塊上的附註,高度為 150 像素或更短,因為這些圖塊上的附註一律會顯示為懸停附註。
- 公開 Look 的懸停附註。
Looker 會在懸停附註中套用下列規則:
- 移除的元素和屬性。Looker 會移除
<style>元素 (包括其內容)、<table>元素,以及style、class和id屬性。移除<table>元素內的文字後,系統會顯示不含表格標記的文字。 - 支援的內容。懸停附註支援連結 (
<a>)、圖片 (<img>,縮放至符合工具提示寬度)、清單 (<ul>、<ol>、<li>)、水平線 (<hr>) 和標題 (<h1>至<h6>)。此外,也支援文字格式和版面配置元素,例如<b>、<br>、<code>、<div>、<em>、<i>、<p>、<pre>、<s>、<small>、<span>、<strong>、<sub>、<sup>和<u>。 - 高度限制。懸停附註的高度上限為 300 像素。在資訊主頁上,如果滑鼠游標停留在較長的懸停附註上,附註內容會在工具提示中捲動。
- 空白記事。如果清理後沒有任何可見內容 (例如,記事僅包含
<style>元素或空白<table>元素),Looker 會隱藏資訊圖示。
顯示在圖表上方或下方的圖塊附註,支援標準允許的 HTML 代碼、HTML 代碼屬性和 CSS 屬性。不過,如果 KPI (單一值) 和單一值 (舊版) 圖塊的高度不超過 150 像素,則不在此限,因為這類附註一律會顯示為懸停附註。
允許的 HTML 代碼
瀏覽器只會轉譯特定 HTML 標記。任何其他標記都會從算繪的 HTML 中移除。
以下是 Looker 支援的 HTML 代碼清單:
a
abbr
acronym
address
area
article
aside
audio
b
bdi
bdo
big
blockquote
br
button
canvas
caption
center
cite
code
col
colgroup
datalist
dd
del
details
dfn
dir
div
dl
dt
em
fieldset
figcaption
footer
h1
h2
h3
h4
h5
h6
header
ins
hr
i
img
kbd
label
legend
li
map
mark
menu
meter
nav
ol
output
p
pre
progress
q
s
samp
section
small
source
span
strike
strong
sub
summary
sup
table
tbody
td
tfoot
th
thead
time
tr
track
tt
u
ul
var
video
允許的 HTML 代碼屬性
瀏覽器只會顯示特定 HTML 屬性。任何其他屬性都會從算繪的 HTML 中移除。這也適用於 HTML style 標記的 CSS 屬性。
以下是 Looker 支援的 HTML 屬性清單:
abbr
accept
accept-charset
accesskey
action
align
alt
autoplay
axis
border
cellpadding
cellspacing
char
charoff
charset
checked
cite
class
clear
color
cols
colspan
compact
controls
controlslist
coords
datetime
dir
disabled
enctype
for
frame
headers
height
href
hreflang
hspace
id
ismap
label
lang
longdesc
loop
loopcount
loopend
loopstart
maxlength
media
method
multiple
muted
name
nohref
noshade
nowrap
poster
preload
prompt
readonly
rel
rev
rows
rowspan
rules
scope
selected
shape
size
span
src
start
style
summary
tabindex
target
title
type
usemap
valign
value
vspace
width
xml:lang
HTML style 標記允許的 CSS 屬性
以下是 Looker 支援的 CSS 屬性清單:
-moz-border-radius
-moz-border-radius-bottomleft
-moz-border-radius-bottomright
-moz-border-radius-topleft
-moz-border-radius-topright
-moz-box-shadow
-moz-outline
-moz-outline-color
-moz-outline-style
-moz-outline-width
-o-text-overflow
-webkit-border-bottom-left-radius
-webkit-border-bottom-right-radius
-webkit-border-radius
-webkit-border-radius-bottom-left
-webkit-border-radius-bottom-right
-webkit-border-radius-top-left
-webkit-border-radius-top-right
-webkit-border-top-left-radius
-webkit-border-top-right-radius
-webkit-box-shadow
azimuth
background
background-attachment
background-color
background-image (請注意,不支援 url)
background-position
background-repeat
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
box-shadow
caption-side
clear
color
cue
cue-after
cue-before
cursor
direction
display
elevation
empty-cells
float
font
font-family
font-size
font-stretch
font-style
font-variant
font-weight
height
image()
letter-spacing
line-height
linear-gradient()
list-style
list-style-image
list-style-position
list-style-type
margin
margin-bottom
margin-left
margin-right
margin-top
max-height
max-width
min-height
min-width
outline
outline-color
outline-style
outline-width
overflow
padding
padding-bottom
padding-left
padding-right
padding-top
pause
pause-after
pause-before
pitch
pitch-range
quotes
radial-gradient()
rect()
repeating-linear-gradient()
repeating-radial-gradient()
rgb()
rgba()
richness
speak
speak-header
speak-numeral
speak-punctuation
speech-rate
stress
table-layout
text-align
text-decoration
text-indent
text-overflow
text-shadow
text-transform
text-wrap
unicode-bidi
vertical-align
voice-family
volume
white-space
width
word-spacing
word-wrap