tirkarthi commented on code in PR #28894:
URL: https://github.com/apache/airflow/pull/28894#discussion_r1070221025


##########
airflow/www/app.py:
##########
@@ -81,10 +82,18 @@ def create_app(config=None, testing=False):
 
     flask_app.config["PERMANENT_SESSION_LIFETIME"] = 
timedelta(minutes=settings.get_session_lifetime_config())
     flask_app.config.from_pyfile(settings.WEBSERVER_CONFIG, silent=True)
-    flask_app.config["APP_NAME"] = conf.get(section="webserver", 
key="instance_name", fallback="Airflow")
     flask_app.config["TESTING"] = testing
     flask_app.config["SQLALCHEMY_DATABASE_URI"] = conf.get("database", 
"SQL_ALCHEMY_CONN")
 
+    instance_name = conf.get(section="webserver", key="instance_name", 
fallback="Airflow")
+    instance_name_has_markup = conf.getboolean(
+        section="webserver", key="instance_name_has_markup", fallback=False
+    )
+    if instance_name_has_markup:
+        instance_name = re.sub(r"<[^<]+?>", "", instance_name)

Review Comment:
   Parsing html with regex can be tricky. Please see this answer 
https://stackoverflow.com/a/4869782/2610955 and also 
https://blog.codinghorror.com/parsing-html-the-cthulhu-way/. The question has 
several options and also discusses handling `&amp;` . Since beautifulsoup is 
already a dependency maybe it can be used.
   
   ```python
   python      
   Python 3.10.6 (main, Aug  2 2022, 15:11:28) [GCC 9.4.0] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import bs4
   >>> from bs4 import BeautifulSoup
   >>> b = BeautifulSoup("<b>Bold Site Title Test</b>")          
   >>> b.get_text()
   'Bold Site Title Test'
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to