为帮助防范安全漏洞,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 许可清单和高度限制,这些限制不适用于在可视化图表上方或下方显示的备注。这些限制适用于以下悬停备注:
- 显示位置设置为悬停在图标上时的信息中心图块备注(或具有
display: hover或note_display: hover的 LookML 信息中心元素)。 - 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 属性。高度不超过 150 像素的 KPI(单个值)和单个值(旧版)图块上的备注是个例外,因为这些备注始终会呈现为悬停备注。
允许的 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