We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 151a7d2 commit 873f6f8Copy full SHA for 873f6f8
files/image_config/updategraph/updategraph
@@ -29,9 +29,14 @@ if [ "$src" = "dhcp" ]; then
29
30
HOSTNAME=`hostname -s`
31
GRAPH_URL=`sonic-cfggen -t /tmp/dhcp_graph_url -a "{\"hostname\": \"$HOSTNAME\"}"`
32
+ URL_REGEX='^(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'
33
+ if [[ ! $GRAPH_URL =~ $URL_REGEX ]]; then
34
+ echo "\"$GRAPH_URL\" is not a valid url. Skipping graph update."
35
+ exit 0
36
+ fi
37
if [ "$dhcp_as_static" = "true" ]; then
- sed -i "/src=d/d" /etc/sonic/updategraph.conf
- echo "src=$GRAPH_URL" >> /etc/sonic/updategraph.conf
38
+ sed -i "/src=/d" /etc/sonic/updategraph.conf
39
+ echo "src=\"$GRAPH_URL\"" >> /etc/sonic/updategraph.conf
40
fi
41
else
42
GRAPH_URL=$src
0 commit comments