From 88e6a1492eb5fda9f702f5c830b18e5b60da2743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 11 Sep 2018 09:38:27 +0200 Subject: [PATCH] Fix patch source --- scripts/_common.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a3b94b0..bc29da5 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,7 +18,7 @@ config_riot() { install_source() { ynh_setup_source $final_path/ - + # if the default homeserver is external we dont add the sso support if [[ $(yunohost domain list | grep "$default_home_server") ]] then @@ -27,16 +27,16 @@ install_source() { test -n $cert_path && cp "$cert_path" $final_path/crt.pem chmod 600 $final_path/crt.pem chown $app:root $final_path/crt.pem - + cp ../sources/get_user_token.php $final_path/ - + # Patch the riot bundle.js file # This file is a minified javascript so it's not possible to use the standrad patch because everything is only on one line. # The other problem is that some variable a renamed to be more short. # Here this variable is named unamed_object. By the regular expression we will be able to get this name and to put in the new code. - + # To make the code more readable (for debug), we can use the tool js-beautify available here : https://github.com/beautify-web/js-beautify - + # We escape all char witch could be a problem in regular expression. escape_string() { a=${a//'\'/'\\'} @@ -47,10 +47,12 @@ install_source() { a=${a//'}'/'\}'} a=${a//'.'/'\.'} a=${a//'*'/'\*'} + a=${a//'^'/'\^'} + a=${a//'$'/'\$'} } # We get the name of the Lifecycle objet - Lifecycle_object_name=$(egrep -o "onLoggedIn:\w+\.setLoggedIn," bundle.js $final_path/bundles/*/bundle.js | egrep -o ":\w+\." | egrep -o "\w") + Lifecycle_object_name=$(egrep -o 'onLoggedIn:[\w\$]+\.setLoggedIn,' $final_path/bundles/*/bundle.js | egrep -o ':[\w\$]+\.' | egrep -o '[\w\$]') # We get the part witch we need to patch and create a regular expression a='case"start_login":this.setStateForNewView({view:unnamed_object.LOGIN}),this.notifyNewScreen("login");break;'