Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_language_name for unknown languages #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/geshi.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public function error() {
*/
public function get_language_name() {
if (GESHI_ERROR_NO_SUCH_LANG == $this->error) {
return $this->language_data['LANG_NAME'] . ' (Unknown Language)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have this set even in case of errors so there's no need for every location to do some special check for such situations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this comment. Are you suggesting to set $this->language_data['LANG_NAME'] in set_language() when the language can't be found?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Having one line access $this->language, while everything else accesses $this->language_data['LANGUAGE_NAME'] seems rather inconsistent. And as most of the parser assumes there's some (somewhat) consistent structure in $this->langauge_data anyway we just might opt to have set_language do that setup instead if some error happens.

return $this->language . ' (Unknown Language)';
}
return $this->language_data['LANG_NAME'];
}
Expand Down